Newer Version Available

This content describes an older version of this product. View Latest

Files Resources

Information about the specified file, including content, rendered version, and sharing.

Available resources are:

Resource Description
/chatter/files/fileId Returns details about the specified file. Can also be used to rename a file, upload a new version of an existing file, move a file to a different folder, and delete a file.
/chatter/files/fileId/content Returns the content of the file. The content is streamed as the body of the response.
/chatter/files/fileId/file-shares Returns information about the objects with which the specified file has been shared. Objects can be users, groups, or records. Can also be used to share the specified file with users.
/chatter/files/fileId/file-shares/link A description of a file shared as a link. Create, access, and delete a file’s share link.
/chatter/files/fileId/rendition A rendition of the file. A rendition is a binary preview of the file. The format of the binary depends on the format specified in the request.
/chatter/files/batch/fileIds Information about a list of files, specified by file IDs. Get information about a list of files and delete a list of files.

File Information

Returns details about the specified file. Can also be used to rename a file, upload a new version of an existing file, move a file to a different folder, and delete a file.

To upload a new version of an existing file, make a POST request. You must upload the new version as a binary part in a multipart/form-data request. See Uploading Binary Files. To upload a new file to the Files tab, use /chatter/users/me/files.

Resource
1/chatter/files/fileId
Available since version
24.0
HTTP methods
GET, POST, PATCH, DELETE, or HEAD

POST, PATCH, and DELETE available since version 26.0.

Note

Request body for POST
Root XML tag
<fileInput>
JSON
1{
2     "desc" : "Employee Survey Results",
3     "title" : "emp_surv_results"
4}
Properties
Name Type Description Available Version
desc String Description of the file to be uploaded. 24.0
isInMyFileSync Boolean true if the file is included in the user’s Salesforce Files folder, and is synced between that folder and Chatter; false otherwise. 30.0 (pilot only)
parentFolderId String ID of the containing folder. 30.0 (pilot only)
title String Title of the file. 24.0
Request parameters for POST
Name Type Description Available Version
desc String Description of the file to be uploaded. 26.0
isDataSync Boolean The request is automatically generated by an automated client. 30.0 (pilot only)
isInMyFileSync Boolean true if the file is included in the user’s Salesforce Files folder, and is synced between that folder and Chatter; false otherwise. 30.0 (pilot only)
title String Title of the file. 26.0
Request parameters for GET and HEAD

Get information about the specified file.

Name Type Description Available Version
versionNumber Integer Specify an existing version number for the file. If not specified, the latest version is returned. 23.0
Request parameters for PATCH

Update the title or sync state of a file or move a file to a different folder.

Name Type Description Available Version
title String A new title for the file 26.0
isInMyFileSync Boolean true if the file is included in the user’s Salesforce Files folder, and is synced between that folder and Chatter; false otherwise. 30.0 (pilot only)
parentFolderId String ID of the containing folder 30.0 (pilot only)
Response body for GET, POST, PATCH, and HEAD
File Detail
Response body for DELETE
Returns a status code of 204.
Example
This PATCH request updates the title of a file:
1/chatter/files/069D00000001FHF?title=A+New+Title

File Content

Returns the content of the file. The content is streamed as the body of the response.

Resource
1/chatter/files/fileId/content
Available since version
24.0
HTTP methods
GET
Request parameters
Name Type Description Available Version
versionNumber Integer Specify an existing version number for the file. If not specified, the latest version is returned. 23.0
Response body
Binary stream of the file content.

File Shares

Returns information about the objects with which the specified file has been shared. Objects can be users, groups, or records. Can also be used to share the specified file with users.

Resource
1/chatter/files/fileId/file-shares
Available since version
24.0
HTTP methods
GET, HEAD, POST

POST is available in versions 30.0 and later.

Request parameters for GET
In versions 30.0 and later, the first share returned in a GET request is the organization record share. In communities, the first share returned is the network record share.
Name Type Description Required or Optional Available Since
page Integer An integer greater than 0 specifying a page of topics. The default value is zero. Optional 24.0
pageSize Integer Specifies the number of items per page. Valid values are between 1 and 100. The default value is 25. Optional 24.0
Request body for POST
Root XML tag
<fileShares>
JSON example
1{
2  "message": "I shared a document with you.",
3  "shares": [
4     { "id": "005D0000001Az4l", "sharingType": "V" },
5     { "id": "005D0000001B2ny", "sharingType": "C" }
6   ]
7}
Properties
Name Type Description Available Version
message String Private message body that’s sent to the recipients. If Salesforce Communities is enabled, an email is sent instead of a private message. 30.0
shares Share Input[] Collection of Share Input request bodies 30.0
Request parameters for POST
Parameters for sharing a file with users
Name Type Description Required or Optional Available Since
id(1–9) String List of up to 9 user IDs to share this file with. This list must match the list of sharing types. Required 30.0
message String Private message body that’s sent to the recipients. If Salesforce Communities is enabled, an email is sent instead of a private message. Optional 30.0
sharingType(1–9) String List of sharing types, either C for collaborator or V for viewer. This list must match the list of user IDs. Required 30.0
Response body for GET and POST
File Shares Page
Example for POST
This example uses request parameters to share a file with two users.
1POST /chatter/files/069D00000001JDU/file-shares?​id1=005D0000001LL8O&id2=005D0000001QdEL&sharingType1=C&sharingType2=V
This example uses a request body to share the same file with the same users.
1POST /chatter/files/069D00000001JDU/file-shares
2
3{
4  "shares": [
5     { "id": "005D0000001LL8O", "sharingType": "C" },
6     { "id": "005D0000001QdEL", "sharingType": "V" }
7   ]
8}

File Rendition

A rendition of the file. A rendition is a binary preview of the file. The format of the binary depends on the format specified in the request.

Renditions are processed asynchronously and might not be available immediately after the file has been uploaded.

Note

Resource
1/chatter/files/fileId/rendition
Available since version
24.0
HTTP methods
GET
Request parameters
Name Type Description
page Integer Specify a rendition of a specific page. The first page is 0. If you don’t specify a specific page, a rendition of the first page is returned.

For a PDF file rendition, the rendition is for the entire document. The only valid value is 0: you can’t get the rendition of a single page.

type String Specify the type of rendition to be returned. Default value is THUMB120BY90. Valid values are:
  • FLASH
  • PDF
  • THUMB120BY90
  • THUMB240BY180
  • THUMB720BY480
Response body
Binary stream of the rendition.

File Information, Batch

Information about a list of files, specified by file IDs. Get information about a list of files and delete a list of files. The number of file IDs you can specify is limited by the length of the URL. In general, you can specify up to 100 file IDs in a comma-separated list.

Resource
1/chatter/files/batch/fileIds
Available since version
26.0
HTTP methods
GET, DELETE
Response body
Batch Result Item