Disk API

Ctrl previousnext Ctrl

Uploading a file (PUT)

Use the PUT method to upload a file to Yandex.Disk.

At the beginning and end of uploading the file, the service checks whether the file exceeds the space available to the user on Disk. If there is not enough space, the service returns a response with the code 507 Insufficient Storage.

Support is provided for transferring compressed files (Content-Encoding: gzip header) and chunked files (Transfer-Encoding: chunked).

Checking for duplicate files

Users often want to upload files to Yandex.Disk that have already been uploaded by someone else. In such cases, Disk can just copy the needed file on the server, without uploading it.

The file is identified by the file size, MD5 checksum, and SHA-256 hash. The following headers are used for passing them:

Etag: <md5 checksum>
Sha256: <SHA-256 hash>
Content-Length: <file size in bytes>

If a duplicate file is found, the server responds with the code 201 Created.

Example of uploading

The app uploads the otpusk.avi file to the /a/ directory on the user's Disk, specifying the checksum and hash for checking for duplicates.

PUT /a/otpusk.avi HTTP/1.1
Host: webdav.yandex.ru
Accept: */*
Authorization: OAuth 0c4181a7c2cf4521964a72ff57a34a07
Etag: 1bc29b36f623ba82aaf6724fd3b16718
Sha256: T8A8H6B407D7809569CA9ABCB0082E4F8D5651E46D3CDB762D02D0BF37C9E592
Expect: 100-continue
Content-Type: application/binary
Content-Length: 103134024

If Yandex.Disk found a duplicate file and doesn't need to upload anything, the server responds with the code 201 Created.

If a duplicate was not found, the server responds with the code 100 Continue, allowing the file to be uploaded in the body of the next request. When the file has been uploaded successfully, the server also responds with the code 201 Created.