shareviahttp icon indicating copy to clipboard operation
shareviahttp copied to clipboard

[Feature request] allow upload from web client

Open inattendu opened this issue 6 years ago • 6 comments

Everything is in the title, it will be a perfect addition, thank you for this great work !

inattendu avatar Jul 26 '18 07:07 inattendu

HTTP protocol by itself does not support upload of files. What you seem to want is FTP server or WebDAV server, but they require different clients

mnalis avatar Mar 10 '21 11:03 mnalis

@mnalis HTTP does allow files upload using POST or PUT requests.

Ammar64 avatar Aug 13 '24 17:08 Ammar64

@Ammar64 you are correct of course...

While I do not remember exact idea I was trying to convey several years ago :smiling_face_with_tear:, it was probably related to the fact that shareviahttp automatically begins download when its / URL is opened, and user have no option to influence that.

To support upload, that auto-download on / would need to replaced with some placeholder page which have separate link for download and separate form (i.e. <form action=POST>) for choosing/uploading file (and shareviahttp web server have some internal CGI-equivalent to support receiving and storing that file somewhere, of course, as just POST to some random location won't upload file in that folder).

Or, better (but less discoverable), keep current / as automated download, and make a new hidden /upload endpoint which when opened would display form for upload (provided you have first started the shareviahttp web server manually on the smartphone)...

mnalis avatar Aug 13 '24 21:08 mnalis

I have the page open when you enter the url and you get both options of Upload / Download.

Ammar64 avatar Aug 13 '24 21:08 Ammar64

I don't use <form method="POST"> as I think you may have to send the file in a multi-part format which requires more work on backend code to handle.

I use the JS XMLHttpRequest and I do xhr.send(form.files[0]) this will send the file and only the file content will be the body of the POST request this make it easier to handle on the Java side

XHR also allows you to get file upload progress unlike <form> which you will have to just wait until you see a sign.

Ammar64 avatar Aug 13 '24 21:08 Ammar64

Ah, you seem to be talking about another FOSS app for similar purpose, https://github.com/Ammar64/Sharing, right @Ammar64 ?

That seems interesting possible alternative for shareviahttp, especially if it remains actively developed.

I've tried it out, and opened a few issues for problems I've encountered (and things which worked great for me in shareviahttp, but are lacking in Sharing app).

mnalis avatar Aug 13 '24 22:08 mnalis