[FEATURE REQUEST] HTTP PUT File Upload
The app is great and has many options for file upload!
But there is one method I am missing, and it is file upload over HTTP PUT. Would it be possible to add that?
It is very simple, it's just the HTTP PUT header + file content.
This would be really great if GPSLogger could provide a file upload to a custom URL instead of sending every line one by one.
I am the dev of reitti and actively promoting GPSLogger over other solutions to get data into it. One thing our users and I noticed it that sending line by line creates a lot of battery drain. In the past I helped myself in sending the data every hour but this kinda works against the live update of the map view. Reitti already has an API-Endpoint to allow posting a GPS file. Someone can mitigate that issue for example by uploading the GPX file via SFTP or other means to a server and having a cron or whatever sending that GPX-File then to reitti. This significantly reduced the battery drain of GPSLogger.
It would be awesome if we can skip the extra step and directly send the GPX-File or a Zip to a custom endpoint.
Would be more than happy to assist or create a PR on this request.
@mendhak would you mind in accepting a PR on this feature or is this something which has no chance in being integrated?
And if so, should this be a toggle in the CustomUrlManager or its own sender?
Anyway, thanks a lot for GPSLogger. I appreciate the work and effort you put in it 👍
Hi all, so I am thinking it makes sense for a file upload to be its own type of sender ie, one of these: https://github.com/mendhak/gpslogger/tree/master/gpslogger/src/main/java/com/mendhak/gpslogger/senders
I'm thinking that a toggle in the existing Custom URL implementation is going to get too confusing and complex because the behaviours are very different. And also the existing Custom URL 'sender' is just a hacked up CSV parser that invokes the Custom URL 'logger' for each line in the file. Adding an option in there that says upload a file can get confusing for users and for me!
That's why it should probably be its own "HTTP Upload" sender type which can follow the known rules of senders. I think a PR on that (a new sender type) would be fine then, I would want to test it myself too.
Some things to think about... it would need some parameters at least to authenticate, right? Would that go into the Headers? Would the HTTP method be hardcoded to PUT? Would the 'boundaries' of the HTTP body be hardcoded.
How does everything I've said so far sound is that making sense.
Hello @mendhak,
that sounds nice. I would follow your advise and add a new HTTP Upload Sender. The user should be able to select the Method and endpoint. On all other parameters I would orient myself on the CustomURL sender. That one seems reasonable to me that it allows for Headers and Parameters. That covers all the needed stuff imo. I am not decided if basic auth is needed, but maybe i am to technical and would just add the header on my own. For the user it probably is nicer, but how many api still need that.
At the moment I do not know what you mean with boundaries. Do you mean the name of the content like [email protected]. This is probably something, the user has to be able to modify. Else it would not work against different endpoints, where they may differ.
Looking forward to get that started. It is a long time I put my hands on some Android development :D
About the boundary thing I might have jumped ahead a bit and potentially unnecesarily. See this answer for what an HTTP file upload looks like, I was thinking about the boundary=----WebKitFormBoundaryePkpFF7tjBAqx29L bit but actually in retrospect that is probably completely irrelevant. Ignore the boundary stuff, I think I was thinking too low level there.
Yes, that should not be relevant at all for this use-case. All we need is the header + data.
The simplest version would be something like this:
PUT /log.xml HTTP/1.1
Host: example.com
Content-type: application/xml
Content-length: 20
filecontent ...