Rclone Delete file through API

What is the problem you are having with rclone?

Leverage operations/deletefile API.

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

rclone v1.65.2

  • os/version: Microsoft Windows 11 Pro 23H2 (64 bit)
  • os/kernel: 10.0.22631.3155 (x86_64)
  • os/type: windows
  • os/arch: amd64
  • go/version: go1.21.6
  • go/linking: static
  • go/tags: cmount

Are you on the latest version of rclone? You can validate by checking the version listed here: Rclone downloads
-->
Yes

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

AWS

The command you were trying to run (eg rclone copy /tmp remote:tmp)

Using http://<rclone base url>/operations/deletefile with Basic authorization and JSON body of 
{"fs": "<rclone remote URL>/<folder>/<file>.txt"}

Output of the Postman call. The idea is to delete a single file within a directory through API.

{
"error": "Didn't find key "remote" in input",
"input": {
"fs": "//.txt"
},
"path": "operations/deletefile",
"status": 400
}

Note:

  1. operations/delete - which deletes the directories, is working fine though in API
  2. operarions/deletefile works fine in CLI (using rclone deletefile) but yields above error in API.

You are not providing correct parameters. Check docs:

operations/deletefile: Remove the single file pointed to

This takes the following parameters:

fs - a remote name string e.g. "drive:"
remote - a path within that remote e.g. "dir"

Example usage:

$ rclone tree myremote:
/
└── testdir
    └── test.txt

Using CLI:

$ rclone deletefile myremote:testdir/test.txt

Using RC (rclone rcd --rc-addr 127.0.0.1:5575 --rc-no-auth):

$ curl -X POST 'http://127.0.0.1:5575/operations/deletefile?fs=myremote:&remote=testdir/test.txt'

Thanks! I was passing them as JSON body and now changed them to querystring and it works fine. Appreciate your help.

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