Download file using REST

What is the problem you are having with rclone?

The REST interface provides most everything I need, except for a clear download endpoint.
The best I can come with is to use rclone cat, but this seems awkward.

$ docker run --rm -d --name rc -p 5572:5572 -e RCLONE_CONFIG_LOCAL_TYPE=local bitnami/rclone rcd --rc-no-auth --rc-addr :5572 -vv
223b5026ec32f608433b587b6af27b52bd2841c938824034aa7ac0de7c285e25
$ echo small-file > file.txt
$ curl 'http://localhost:5572/operations/uploadfile?fs=local:&remote=tmp' -F file.txt=@file.txt
{}
$ curl 'http://localhost:5572/core/command?command=cat&returnType=STREAM_ONLY_STDOUT&arg=%5B%22local:tmp/file.txt%22%5D' -X 'POST'
small-file
{}

The last line sort of works.
Is there a better way?
The output has three extra characters "{}\n". Any good way to prevent them?

Run the command 'rclone version' and share the full output of the command.

$ docker exec -it rc rclone version
rclone v1.58.0
- os/version: debian 10.12 (64 bit)
- os/kernel: 5.4.0-121-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.18
- go/linking: dynamic
- go/tags: none

Which cloud storage system are you using? (eg Google Drive)

Local

A log from the command with the -vv flag

$ docker logs rc
2022/07/01 15:49:27 DEBUG : Configuration directory could not be created and will not be used: mkdir /.config: permission denied
2022/07/01 15:49:27 DEBUG : rclone: Version "v1.58.0" starting with parameters ["rclone" "rcd" "--rc-no-auth" "--rc-addr" ":5572" "-vv"]
2022/07/01 15:49:27 NOTICE: Serving remote control on http://[::]:5572/
2022/07/01 15:51:09 DEBUG : rc: "operations/uploadfile": with parameters map[_request:0xc000618000 fs:local: remote:tmp]
2022/07/01 15:51:09 DEBUG : Creating backend with remote "local:"
2022/07/01 15:51:09 DEBUG : Setting type="local" for "local" from environment variable RCLONE_CONFIG_LOCAL_TYPE
2022/07/01 15:51:09 NOTICE: Config file "/.rclone.conf" not found - using defaults
2022/07/01 15:51:09 DEBUG : fs cache: renaming cache item "local:" to be canonical "/"
2022/07/01 15:51:09 DEBUG : Local file system at /: File to upload is small (11 bytes), uploading instead of streaming
2022/07/01 15:51:09 DEBUG : tmp/file.txt: md5 = a4bb818420ce96406685ade5c8bb2a66 OK
2022/07/01 15:51:09 INFO  : tmp/file.txt: Copied (new)
2022/07/01 15:51:09 DEBUG : tmp/file.txt: Upload Succeeded
2022/07/01 15:51:09 DEBUG : rc: "operations/uploadfile": reply map[]: <nil>
2022/07/01 15:51:31 DEBUG : rc: "core/command": with parameters map[_request:0xc000ad8000 _response:0xc00032a0e0 arg:["local:tmp/file.txt"] command:cat returnType:STREAM_ONLY_STDOUT]
2022/07/01 15:51:31 DEBUG : rc: "core/command": reply map[]: <nil>

I'm not sure what your use case but most folks would use a 'serve' type command to share something via FTP/HTTP/DLNA/etc for a download endpoint and not the remote control daemon as the goal for that is to issue commands (IMO).

rclone serve

You can also run the remote control daemon to interact with the serve command as most folks do that with a mount / remote control combination.

You have to enable the rest GET endpoint - see

--rc-serve is exactly what I needed (and missed). Thank you!

$ docker run --rm -d --name rc -p 5572:5572 -e RCLONE_CONFIG_LOCAL_TYPE=local bitnami/rclone rcd --rc-serve --rc-no-auth --rc-addr :5572 -vv
223b5026ec32f608433b587b6af27b52bd2841c938824034aa7ac0de7c285e25
$ echo small-file > file.txt
$ curl 'http://localhost:5572/operations/uploadfile?fs=local:&remote=tmp' -F file.txt=@file.txt
{}
$ curl http://localhost:5572/%5Blocal:%5D/tmp/file.txt
small-file
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.