to navigate to open Esc to close Search by Algolia

API: Uploading files

Target URL /api.php/Drive/files/upload
Required scope upload
HTTP Method PUT
Output format JSON

The file contents are sent as the request body. The parameters go in the query string.

Request Parameters Reference

Parameter Type Required Description
path string Yes The FileRun path of the target folder. The folder needs to exist. See this page
filePath string Yes The name of the file, optionally preceded by a sub-path relative to the target folder (New-Folder/my-file.ext). The folders of the sub-path are created when they do not exist.
totalSize integer No The total size of the file, in bytes. Defaults to the size of the request body.
startByte integer Yes, unless getOffset is sent The position in the file the request body starts at. 0 for a new upload.
getOffset any No Send it, without a request body, to ask how many bytes of an interrupted upload were received. The response carries the number as offset. Resume the upload from that position.
lastModified integer No Unix timestamp of the modification date of the file. It is applied to the file after the upload. It is also used to skip the transfer of a file which already exists with the same name, the same size and the same date.

How it works

The received bytes are written to a temporary file next to the target. The file is put in place once the received size reaches totalSize, so a large file can be sent in several requests, each with its own startByte. When resuming, startByte must equal the number of bytes already received; otherwise the request is refused and the response carries the expected number as offset. A file of the same name which already exists is updated. When file versioning is on, its previous content is kept as a version.

The response

Every response carries offset, the number of bytes received so far.

When lastModified is sent and the target folder already holds a file of the same name, the same size and the same modification date, nothing is transferred: the response has success set to false and skip set to true. Treat the file as already uploaded.

Example

 1curl -X PUT --header "Authorization: Bearer neY6uAjKO1KqQh98RZZ5DOgYjIPMuu9duvvHGUiN" -T your-file.ext https://amsterdam.demo.filerun.com/api.php/Drive/files/upload/?path=/ROOT/HOME/existing-folder&filePath=New-Folder/my-file.ext&totalSize=123&startByte=0
  • neY6uAjKO1KqQh98RZZ5DOgYjIPMuu9duvvHGUiN - is the previously received "access_token"
  • your-file.ext - is the path of the file you want to upload from the local computer
  • https://demo.filerun.com - is the URL of your FileRun installation
  • /ROOT/HOME/existing-folder - is the remote path where you wish the file to be uploaded. The folder needs to exist and will not be automatically created.
  • New-Folder/my-file.ext - New-Folder is the folder path where you wish the file to be uploaded. This will be automatically created. my-file.ext is the name of your file.
  • totalSize - is the size of the file you wish to upload.
  • startByte - is an integer value specifying the number of bytes where the transfer is being resumed.