HTTP API

General#

note

You can get your Project Key and your Project ID from your Deta dashboard. You need these to tlak with the Deta Drive API.

Root URL#

This URL is the base for all your HTTP requests:

https://drive.deta.sh/v1/{project_id}/{drive_name}

The drive_name is the name given to your drive. If you already have a Drive, then you can go ahead and provide it's name here. Additionally, you could provide any name here when doing any PUT or POST request and our backend will automatically create a new drive for you if it does not exist. There is no limit on how many "Drives" you can create.

Auth#

A Project Key must be provided in the request headers as a value for the X-Api-Key key for authentication and authorization.

Example X-Api-Key: a0kjsdfjda_thisIsYourSecretKey

File Names And Directories#

Each file needs a unique name which identifies the file. Directorial hierarchies are represented logically by the name of the file itself with the use of backslash /.

For example, if you want to store a file world.txt under the directory hello , the name of the file should be hello/world.txt.

The file name must not end with a /. This also means that you can not create an empty directory.

A directory ceases to exist if there are no more files in it.

Endpoints#

Put File#

POST /files?name={name}

Stores a smaller file in a single request. Use this endpoint if the file size is small enough to be sent in a single request. The file is overwritten if the file with given name already exists.

note

We do not accept payloads larger than 10 Mb on this endpoint. For larger uploads, use chunked uploads.

HeadersRequiredDescription
Content-TypeNoThe content type of the file. If the content type is not specified, the file name is used to figure out the content type. Defaults to application/octet-stream if the content type can not be figured out.
Query ParamsRequiredDescription
nameYesThe name of the file. More here.

Initialize Chunked Upload#

Initializes a chunked file upload. If the file is larger than 10 MB, use this endpoint to initialize a chunked file upload.

POST /uploads?name={name}

ParamsRequiredDescription
nameYesThe name of the file. More here.

Upload Chunked Part#

Uploads a chunked part.

POST /uploads/{upload_id}/parts?name={name}&part={part}

note

Each chunk must be at least 5 Mb and at most 10 Mb. The final chunk can be less than 5 Mb.

ParamsRequiredDescription
upload_idYesThe upload_id received after initiating a chunked upload
nameYesThe name of the file. More here.
partYesThe chunk part number, start with 1

End Chunked Upload#

End a chunked upload.

PATCH /uploads/{upload_id}?name={name}

ParamsRequiredDescription
upload_idYesThe upload_id received after initiating a chunked upload
nameYesThe name of the file. More here.

Abort Chunked Upload#

Aboart a chunked upload.

DELETE /uploads/{upload_id}?name={name}

ParamsRequiredDescription
upload_idYesThe upload_id received after initiating a chunked upload
nameYesThe name of the file. More here.

Download File#

Download a file from drive.

GET /files/download?name={name}

ParamsRequiredDescription
nameYesThe name of the file. More here.

List Files#

List file names from drive.

GET /files?limit={limit}&prefix={prefix}&last={last}

ParamsRequiredDescription
limitNoThe limit of number of file names to get, defaults to 1000
prefixNoThe prefix that each file name must have.
lastNoThe last file name seen in a paginated response.

Delete Files#

Content-Type: "application/json"
{
"names": ["file_1", "file_2"]
}
ParamsRequiredDescription
namesYesThe names of the files to delete, maximum 1000 file names