Files Resource
Endpoint
https://{instance}.salesforce.com/services/apexrest/cg/SDrive/files
Methods
GET
POST
PUT
DELETE
Method Details
GET
Request Query Parameters
fileObjectId: ids of the file you want to query
parentId : ids of the parent object of the requested file. If file object type is an S3 object members of this array can be null or invalid input but array lengths must still match.
timeValue : Expiration time of the links in seconds
requestParameters (Optional) : Any remaining parameters will be included as additional query parameters for the Amazon file link(e.g. ('response-content-disposition', 'inline; filename=myfile.png')).
For more information, visit the Amazon documentation:
http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html
Response Body Parameters
fileUrls : JSON array of requested file URLS.
Type: string[]
Status Codes
200 - Object received
403 - Wrong input formatting
404 - False ids
422 - Wrong input semantics
POST
Request Body Parameters
objectId : Id of the parent object this file will be uploaded to
Type: string
multipartUpload : Do multipart Upload, used for big files(currently unavailable)
Type : Boolean
fileType : File Object the new files will be uploaded as.
Type: string
fileProperties : JSON array of file metadata of the uploaded files.
Type: fileProperty[]
policyMap : Key value pairs that represent the additional policy parameters used during upload
Type: string[]
Response Body Parameters
uploadRequestInfo : JSON object that details how to upload a file to Amazon S3
Type: uploadRequestInfo[]
policyMap : Map of policy conditions and theirs values that represent the additional policy parameters used during upload (e.g. ('$Content-Disposition', 'attachment; filename)). For more information, visit the Amazon documentation:
http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html
FileProperty :
fileName : string
fileLocation : string
description : string
relationshipFieldName : string
fileType : string
fileSizeInBytes : string
UploadRequestInfo :
fileName : string
fileLocation : string
fileSize : string
fileType : string
wipFileId : string
signature : string
policy : string
timeStamp : string
awsRegion : string
awsCredential : string
metadataHeaders: object
s3EncryptionType: string
Status Codes
201 - Object properly created
403 - Wrong input formatting
404 - False objectId
406 - Invalid input
412 - Missing input fields
422 - Wrong input semantics
Usage
Use POST to initiate an upload. Creates File Object records on S-Drive. Follow it by uploading the files using the data in uplodRequestInfo to Amazon S3 then finish with the PUT method. Corresponding field names to AWS form fields are as follows.
fileName : used in Content-Disposition
fileLocation : key
fileType : Content-Type
signature : x-amz-signature
policy : policy
timeStamp : x-amz-date
awsCredential : x-amz-credential
s3EncryptionType: x-amz-server-side-encryptionPUT
Request Body Parameters
wipIds : JSON array of Salesforce ids that have completed their uploads to Amazon S3.
Type: string[]versionIds(Optional) : JSON array of AWS S3 version ids ids that have completed their uploads to Amazon S3.
Type: string[]
Response Body Parameters
resultObjects : JSON object that details the status of each file's upload request.
Type: resultObject[]
ResultObject
status : string ( success or fail)
error message : string ( empty if status is success)
wipField : string ( to see which file failed)
Status Codes
200 - Upload complete
403 - Wrong input formatting
404 - False wipIds
422 - Wrong input semantics
Usage
Done after the POST method and uploading files to the correct location in Amazon S3.DELETE
Request Query Parameters
objectId : Id of the parent object.
wipId : Salesforce id of the object that will be deleted from S-Drive and Amazon S3.
Response Body Parameters
resultObjects : JSON object that details the status of each file's delete request.
Type: ResultObject[]
ResultObject
status : string ( success or fail)
error message : string ( empty if status is success)
wipField : string ( to see which file failed)
Status Codes
200 - Object deleted
403 - Wrong input formatting
404 - False objectIds
422 - Wrong input semantics
Usage
Deletes the File from Amazon S3 then removes the file record from Salesforce