Create a new resumable file

Contents

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

Parameter Description Required
Authorization An 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-Type Indicates the media type for the message body. The value must be multipart/related.

Value of type: string
true


Request Query Parameters

Parameter Description Required
done Whether to commit the file after having written its content.

Value of type: boolean

Default: false
false
offset The 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
resolveNameConflict Whether to resolve a conflicting name by appending a number.

Value of type: boolean

Default: false
false


Request Body

Parameter Description Required
Body part 1: cTime The file creation time.

Value of type: dateTime

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

Value of type: string

Default: none
false
Body part 1: mimeType The 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: mimeTypes List 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: mTime The file modification time.

Value of type: dateTime

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

Value of type: string

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

Value of type: string

Default: root
false
Body part 2 The 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 3 The 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

Parameter Description Required
ETag The ETag for the file metadata and content.

Value of type: string
false
Location A 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.1
Host: Endpoint-URL
Authorization: Bearer 25951a7e-ffae-4edb-abb2-5e57d4ffb759
Content-Type: multipart/related;boundary=foo
--foo
{
  "name": "newfile",
  "parentID": "root"
}
--foo

Response


HTTP/1.1 201 Created
Etag: "Ag"
Location: /sdk/v2/files/SCtt6sReL85MCZ-Ds-MrAVR67JkbpPqLKzqpyQnl/resumable
Vary: Origin
Date: Mon, 29 Aug 2016 19:18:19 GMT
Content-Length: 0
Content-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.1
Host: Endpoint-URL
Authorization: Bearer 25951a7e-ffae-4edb-abb2-5e57d4ffb759
Content-Type: multipart/related;boundary=foo
{
  "name": "live_photo.heic",
  "parentID": "root",
  "mimeTypes": ["image/heic", "video/quicktime"]
}
--foo
Content-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 Created
Etag: "Ag"
Location: /sdk/v2/files/H3edQhgTissJUIYpAG7BnzmFja3p4KuBMEUq53IH/resumable
Vary: Origin
Date: Mon, 29 Aug 2016 19:18:19 GMT
Content-Length: 0
Content-Type: text/plain; charset=utf-8

Have question about this section?