Ammar64 / Sharing

Share files and apps on android to other devices using browser
GNU Affero General Public License v3.0
85 stars 8 forks source link

support non-interactive HTTP clients (e.g. wget, curl...) #14

Closed mnalis closed 2 months ago

mnalis commented 3 months ago

It would be great if Sharing would support noninteractive tools like wget or curl.

Perhaps it can have simple endpoint like https://192.168.0.123:2999/dl which would skip all that interactive stuff and just download a file if single (like shareviahttp does), or as a simple tar archive (in case of multiple files).

tar would be better choice than zip - it should be well supported too, and is much simpler, and (unlike .zip which has file directory at the end of the file) also allows for streaming usage like e.g.:

curl -sL https://192.168.0.123:2999/dl | tar xf -

(i.e. unpack file directly as they are coming from the network, instead of having to fully download potentially huge .zip file, and then uncompressing it, which is slower and requires double the space).

Ammar64 commented 3 months ago

Well if you do.

curl http://192.168.1.4:2999/available-downloads

it will get you json which contains a link for each file.

I will consider making a straight forward way for this in the future.

Ammar64 commented 3 months ago

ok I remembered that it doesn't contain a link for each file but rather a uuid which you can use to make a link.

It's a json arrays that contains json objects each represnts something you can download either an app or a file.

Here is an example of a json array contains one object

[{"uuid":"78b93f5d-9c54-4919-906b-adf2ac3f859a","name":"App Manager","size":18042042,"type":"app","hasSplits":false}]

To download using curl just make a link using a uuid like this if uuid = 78b93f5d-9c54-4919-906b-adf2ac3f859a.

then the link would look like this. http://192.168.1.4:2999/download/78b93f5d-9c54-4919-906b-adf2ac3f859a

assuming 192.168.1.4 is your phone local ip address.

This is the way the browser interact with the app when you press Receive it request the json then use its info to display items which you can download in a list and when you click an item it uses the download link from the uuid.

Sorry because I said json contains link nobody remember his old code.

Ammar64 commented 3 months ago

I would make it so if you request the /ad path (which stands for available downloads) it lists items in the terminal in a readable way (not json) with links then you can copy the link you want and download.

If you have better way feel free to suggest.

Ammar64 commented 2 months ago

Ops I forgot to close this