Create a new resumable file


Create a new resumable file.

Endpoint URL: {network.internalDNSName or network.proxyURL} received in DeviceInformation

Concurrent Access

When multiple users are interacting with the system simultaneously, it's your responsibility to maintain data integrity while making concurrent writes to resumable files. When you are using resumable files non-concurrently, it is recommended to use etags always.

Request Syntax

POST /v2/files/resumable


Request Headers

ParameterDescriptionRequired
AuthorizationAn access token with nas_read_write scope as well as a File Permission with value WriteFile or FileOwner for a parent.

Value of type: string
true
Content-TypeIndicates the media type for the message body. The value must be multipart/related.

Value of type: string
true


Request Query Parameters

ParameterDescriptionRequired
doneWhether to commit the file after having written its content.

Value of type: boolean

Default: false
false
offsetThe offset in the resumable file where to start writing the content. If not zero, the file will be sparse up to this offset.

Value of type: integer

Default: 0
false
resolveNameConflictWhether to resolve a conflicting name by appending a number.

Value of type: boolean

Default: false
false


Request Body

ParameterDescriptionRequired
Body part 1: cTimeThe file creation time.

Value of type: dateTime

Default: Current time
false
Body part 1: hiddenWhich OS the file is hidden on. Possible values are mac, linux, windows or none.

Value of type: string

Default: none
false
Body part 1: mimeTypeThe Media Type of the file. Use application/x.wd.dir for directories.

Value of type: string

Default: Automatically detected or `application/octet-stream`
false
Body part 1: mimeTypesList of mimeTypes for all the contents if multiple contents are provided in Body part 2. If the first element is an empty string, it will be autodetected.

Value of type: array of strings

Default: Empty array
false
Body part 1: mTimeThe file modification time.

Value of type: dateTime

Default: Current time
false
Body part 1: nameThe name of the file.

Value of type: string

Default: Automatically generated
false
Body part 1: parentIDThe parent ID or the alias root.

Value of type: string

Default: root
false
Body part 2The contents of the file. If there is a "multipart/related" content, each part will be stored as a separate content. Parts should match the mimeTypes array length.

Default: Zero bytes
false
Body part 3The preview source of the contents (only JPEG accepted). Will be used to generate image previews.

Default: Zero bytes
false


201 Response

The normal case will be 201.

Response Headers

ParameterDescriptionRequired
ETagThe ETag for the file metadata and content.

Value of type: string
false
LocationA relative URL to the created file's endpoint.

Value of type: string
false


Example

Sample request to create a new regular file.

Request

POST /sdk/v2/files/resumable HTTP/1.1Host: Endpoint-URLAuthorization: Bearer 25951a7e-ffae-4edb-abb2-5e57d4ffb759Content-Type: multipart/related;boundary=foo--foo{  "name": "newfile",  "parentID": "root"}--foo

Response

HTTP/1.1 201 CreatedEtag: "Ag"Location: /sdk/v2/files/SCtt6sReL85MCZ-Ds-MrAVR67JkbpPqLKzqpyQnl/resumableVary: OriginDate: Mon, 29 Aug 2016 19:18:19 GMTContent-Length: 0Content-Type: text/plain; charset=utf-8


Example (Multiple Contents)

Sample request to create a new resumable file with multiple contents.

Request

POST /sdk/v2/files/resumable HTTP/1.1Host: Endpoint-URLAuthorization: Bearer 25951a7e-ffae-4edb-abb2-5e57d4ffb759Content-Type: multipart/related;boundary=foo{  "name": "live_photo.heic",  "parentID": "root",  "mimeTypes": ["image/heic", "video/quicktime"]}--fooContent-Type: multipart/related; boundary=bar--bar[content of live_photo.heic]--bar[content of live_photo.mov]--bar----foo[content of live_photo_preview.jpg]--foo--

Response

HTTP/1.1 201 CreatedEtag: "Ag"Location: /sdk/v2/files/H3edQhgTissJUIYpAG7BnzmFja3p4KuBMEUq53IH/resumableVary: OriginDate: Mon, 29 Aug 2016 19:18:19 GMTContent-Length: 0Content-Type: text/plain; charset=utf-8