Adding resource meta information
You can specify additional custom attributes for any writable file or folder. These attributes will be returned in response to all requests for resource meta information (list of all files, recently uploaded files, and others).
Request format
Use the PATCH method to send a request for adding meta information.
https://cloud-api.yandex.net/v1/disk/resources/
? path=<resource path>
& [fields=<properties to include in the response>]
- path*
-
The path to the resource relative to the Yandex Disk root directory. The path to the resource in Trash should be relative to the Trash root directory.
The path in the parameter value should be encoded in URL format.
- fields
-
List of JSON properties to include in the response. Keys not specified in this list are omitted when generating a response. If the parameter isn't specified, the response is returned in full without omitting anything.
Key names should be separated by commas, and embedded keys should be separated by dots. For example:name,_embedded.items.path
.
* Required parameter.
Request body
Pass the added attributes within the custom_properties
object in the response body (you can pass any parts of the Resource object, but everything except for custom_properties
will be ignored). Attributes can only be of the name:value
type, so you can't use arrays or parent objects.
Restriction
The length of the custom_properties
object (the names and values of embedded keys along with syntactic symbols) is limited to 1024 characters.
The passed attributes are added to the existing ones. For example, you pass the following object with the foo
and bar
attributes:
"custom_properties": {"foo":"1", "bar":"2"}
If the custom_properties
object doesn't exist in the resource meta information, the API simply adds the passed object to it.
If this object already exists (for example, "custom_properties": {"oof":"3", "bar":"0"}
), the API updates the keys with the same names and adds the new ones. In the resource meta information, the object will look like this:
"custom_properties": {"oof": "3", "bar":"0", "foo":"1"}
To delete an attribute, pass it with the null
value. For example:
"custom_properties": {"foo": null}
Response format
If the request is processed without errors, the API returns the 200 OK
code and meta information about the requested resource within the Resource object in the response body.
If the request caused an error, the relevant response code is returned, and the response body contains an error description.
For non-empty folders, the response includes a ResourceList object (under the _embedded
name). Each resource in the folder is an element of the items
array. Regardless of the requested sort, resources in the array are ordered by type: nested folders go first, followed by folder files.
{
"public_key": "HQsmHLoeyBlJf8Eu1jlmzuU+ZaLkjPkgcvmokRUCIo8=",
"_embedded": {
"sort": "",
"path": "disk:/foo",
"items": [
{
"path": "disk:/foo/bar",
"type": "dir",
"name": "bar",
"modified": "2014-04-22T10:32:49+04:00",
"created": "2014-04-22T10:32:49+04:00"
},
{
"name": "photo.png",
"preview": "https://downloader.disk.yandex.ru/preview/...",
"created": "2014-04-21T14:57:13+04:00",
"modified": "2014-04-21T14:57:14+04:00",
"path": "disk:/foo/photo.png",
"md5": "4334dc6379c8f95ddf11b9508cfea271",
"type": "file",
"mime_type": "image/png",
"size": 34567
}
],
"limit": 20,
"offset": 0
},
"name": "foo",
"created": "2014-04-21T14:54:42+04:00",
"custom_properties": {"foo":"1", "bar":"2"},
"public_url": "https://yadi.sk/d/AaaBbb1122Ccc",
"modified": "2014-04-22T10:32:49+04:00",
"path": "disk:/foo",
"type": "dir"
}
Response elements
Element |
Description |
|
Key of a published resource. It's included in the response only if the specified file or folder is published. |
|
Link to a published resource. It's included in the response only if the specified file or folder is published. |
|
The resources in the folder (contains the ResourceList object). It's included in the response only when the folder meta information is requested. |
|
Link to a preview image of the file. It's included in the response only for supported image formats. The preview can only be requested with the OAuth token of a user who has access to the file. |
|
Resource name. |
|
The object contains all attributes specified by the Adding resource meta information request. Contains only keys of the |
|
The date and time when the resource was created, in ISO 8601 format. |
|
The date and time when the resource was modified, in ISO 8601 format. |
|
Full path to the resource on Yandex Disk. The meta information of the published folder indicates paths relative to the folder. For published files, the key value is always "/". For a resource in Trash, this attribute may have a unique ID added to it (for example, |
|
Path to the resource before it was moved to Trash. Only included in the response to a meta information request related to a resource in Trash. |
|
MD5 hash of the file. |
|
Resource type:
|
|
The MIME type of the file. |
|
File size. |
Element |
Description |
|
The field by which the list is sorted. |
|
The key of the published folder that contains resources from this list. It's included in the response only if a public folder's meta information is requested. |
|
Array of resources (Resource) located in the folder. Regardless of the requested sort, resources in the array are ordered by type: nested folders go first, followed by folder files. |
|
The maximum number of items in the |
|
The offset from the first resource in the folder to the top of the list. |
|
The path to the folder whose contents are described in the For a public folder, the attribute value is always "/". |
|
The total number of resources in the folder. |
The path to the resource relative to the Yandex Disk root directory. The path to the resource in Trash should be relative to the Trash root directory.
The path in the parameter value should be encoded in URL format.
List of JSON properties to include in the response. Keys not specified in this list are omitted when generating a response. If the parameter isn't specified, the response is returned in full without omitting anything.
Key names should be separated by commas, and embedded keys should be separated by dots. For example: name,_embedded.items.path
.
Required parameter.