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:
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.
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.