Upload Custom Rendition
/documents/api/1.1/files/{fileId}/data/rendition
Upload a custom rendition file to the latest file version, using a multipart request. The given name will be used to uniquely identify this rendition within a file version.
Request
- multipart/form-data
- fileId
-
Type:
stringRequired:trueGlobally unique identifier (GUID) for the file.
- accessToken
-
Type:
stringApplink access token authorizing the current user to access the parent folder or this file. This parameter is mandatory if
appLinkIDis used. It can be used as accessToken or AccessToken. - appLinkID
-
Type:
stringApplink ID authorizing the current user to access the parent folder or this file. Any time the parameter
appLinkIDis used, a parameteraccessTokenmust be provided as well. To work, this applink must have at least the contributor role granted. It can be used as appLinkID or AppLinkID. - dAccessCode
-
Type:
stringAccess code needed to use protected public links. It needs to be sent as part of a Cookie header in the following format:
dAccessCode-<linkID>=<passcodeValue> - linkID
-
Type:
stringPublic link ID of a public link authorizing the current user to access this file. It can be used as linkID or LinkID.
- file
-
Type:
fileRequired:trueCustom rendition file to upload. - jsonInputParameters
-
Type:
stringRequired:trueYou can use this parameter to include the
nameparameter and thedescriptionparameter as a JSON payload with the request.Set
nameas a unique identifier for this custom rendition within the file's latest revision scope.The
For example:nameparameter must be sent as a part of this JSON payload. This parameter is required.{"name ": "smallCustomRendition"
}The following restrictions apply to
name:- The length of
namecan't exceed 28 characters. - The
nameparameter isn't case-sensitive; that is,smallRenditionandsmallrenditionare considered identical.
Don't use the following characters in
name:/ \ < > [ ] { } = $ % ' * " ? : # & ^ . , | The
descriptionparameter can be sent as a part of this JSON payload. This parameter is optional.For example:
{"name ": "smallCustomRendition",
"description ": "This is a small rendition version for this file"
} - The length of
Response
- application/json
- application/xml
Created. The request was fulfilled and the new resource was created.
- errorCode
-
Type:
numberAn error code of zero (0) indicates no errors. - id
-
Type:
stringGlobally unique identifier (GUID) of the file. - type
-
Type:
stringItem typefile.
Example application/json
{
"id":"D3C1C1F319CFE6B102095C5DT0000000000100000001",
"type":"file",
"errorCode":"0"
}
A mandatory parameter is missing or an invalid parameter was provided.
Forbidden if the user does not have write permission.
File ID is not found.
A custom rendition with the given name already exists in the latest version.
Examples
The following example uploads a custom rendition image named small to the latest revision of an existing file.
POST .../files/D3C1C1F319CFE6B102095C5DT0000000000100000001/data/rendition
Request Header
Content-Type: multipart/form-data; boundary=---------------------------7dc7c172076a
Request Body
-----------------------------7dc7c172076a
Content-Disposition: form-data; name="file"; filename="smallJellyfish.png"
Content-Type: image/jpeg
<CONTENT OF IMAGE FILE>
-----------------------------7dc7c172076a
Content-Disposition: form-data; name="parameters"
Content-Type: application/json
{
"name":"small",
"description":"jellyfish small custom rendition"
}
-----------------------------7dc7c172076a--
HTTP Status Code
HTTP_STATUS = 200
JSON Response
{
"errorCode": "0",
"id": "D3C1C1F319CFE6B102095C5DT0000000000100000001",
"type": "file"
}
Example 2
The following example uploads a custom rendition image named small to the latest revision of an existing file. The latest revision of this file already has a custom rendition named small.
POST .../files/D3C1C1F319CFE6B102095C5DT0000000000100000001/data/rendition
Request Header
Content-Type: multipart/form-data; boundary=---------------------------7dc7c172076a
Request Body
-----------------------------7dc7c172076a
Content-Disposition: form-data; name="file";
filename="smallJellyfish.png"
Content-Type: image/jpeg
<CONTENT OF IMAGE FILE>
-----------------------------7dc7c172076a
Content-Disposition: form-data; name="parameters"
Content-Type: application/json
{
"name":"small",
"description":"jellyfish small custom rendition version 2"
}
-----------------------------7dc7c172076a--
HTTP Status Code
HTTP_STATUS = 409
JSON Response
{
"errorCode": "-17",
"errorKey": "!csRenditionsUnableToAddDuplicateName,small",
"errorMessage": "The 'small' attachment already exists. No attachments will be added.",
"errorType": "file",
"id": "D3C1C1F319CFE6B102095C5DT0000000000100000001",
"title": "The 'small' attachment already exists. No attachments will be added.",
"type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}
Example 3
The following example uploads a custom rendition image without the name parameter to the latest revision of an existing file.
POST .../files/D3C1C1F319CFE6B102095C5DT0000000000100000001/data/rendition
Request Header
Content-Type: multipart/form-data; boundary=---------------------------7dc7c172076a
Request Body
-----------------------------7dc7c172076a
Content-Disposition: form-data; name="file";
filename="smallJellyfish.png"
Content-Type: image/jpeg
<CONTENT OF IMAGE FILE>
-----------------------------7dc7c172076a
Content-Disposition: form-data; name="parameters"
Content-Type: application/json
{
"description":"this is my custom rendition"
}
-----------------------------7dc7c172076a--
HTTP Status Code
HTTP_STATUS = 400
JSON Response
{
"errorCode": "-97",
"errorKey": "!csRequiredFieldMissing,name",
"errorMessage": "Required field 'name' is missing.",
"errorType": "file",
"id": "D3C1C1F319CFE6B102095C5DT0000000000100000001",
"title": "Required field 'name' is missing.",
"type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}
Example 4
The following example uploads a custom rendition image named <code>applinkRendition</code> to the latest revision of an existing file. The example uses an applink ID because this file is under a folder structure not owned by or shared with the current user. The applink ID and access token are submitted in the request header.
POST .../files/DED694950C14AFF280419F9AB5D17B95F47087F4E518/data/rendition
Request Header
Content-Type: multipart/form-data; boundary=---------------------------7dc7c172076a appLinkID: LF5Bxj4TPo_p4n4qWn0tbKTicR2cTUJKv7X_ng9E7ry93rRuDokPqS1d6-wKwhb_wtcGYFDsI_cNMxeKQ-HR-FXQhiVoGRTYM_MPZY8qpICfYU94mmnMjM_cvsRhKMzc0NJgvwEJfqqDwPsAVrhc8cmg== accessToken: 352FpiMmW66PeYI1Gh5b83I9CXRwZhLfYAu4TXdqpzD8uNKUBMZVVJ3ZvivUW8kQ
Request Body
-----------------------------7dc7c172076a Content-Disposition: form-data; name="file"; filename="appLinkCustomRendition.png" Content-Type: image/jpeg <CONTENT OF IMAGE FILE>
-----------------------------7dc7c172076a
Content-Disposition: form-data; name="parameters"
Content-Type: application/json
{
"name":"applinkRendition",
"description":"custom rendition via applink"
}
-----------------------------7dc7c172076a--
HTTP Status Code
HTTP_STATUS = 200
JSON Response
{
"errorCode": "0",
"id": "DED694950C14AFF280419F9AB5D17B95F47087F4E518",
"type": "file"
}