You can use SDriveTools API calls for uploading the S-Drive Attachments/Folders Files to Amazon. For this, you will need to use below methods:

  • initializeUpload()

  • completeUpload()

  • cancelUpload()

  • getAccessKey()

  • getBucketName()

  • getS3Endpoint()

Before upload, you must first initialize attachment upload. Initializing the attachment upload creates work in progress (WIP) file(s) objects (S3Object, Case File, My Example Object File, etc.) and calculates the required file information for the upload process. For initializing attachment upload, use initializeUpload() method.
The next step is uploading the file(s) to Amazon using html upload. When you upload file(s) to Amazon, You should use the information which has been returned by initializeUpload() as well as the values retrieved from getAccessKey(), getBucketName() and getS3Endpoint() methods.
If upload is successful, you must complete attachment upload. Complete attachment upload means updating WIP file records created during initialize upload call and set the WIPc field value as false. For completing attachment upload, use completeUpload() method.
If upload fails, you must cancel upload. Canceling upload means deleting the WIP file records. For canceling attachment upload, use cancelUpload() method.
You can also upload the big files using multipart uploads. For this, you will need below methods.

  • initializeMultiPartUpload()

  • copyPartMultiPartUpload()

  • completeMultiPartUpload()

  • deleteMultiParts()

  • abortMultiPartUpload()

Html Policy

"expiration": "2014-03-12T12:47:13.893Z",
{"acl": "private" },
{"bucket": "cg--81..." },
["starts-with", "$Content-Disposition", "attachment; filename"],
["starts-with", "$key", "a038…"],
{"x-amz-server-side-encryption": "AES256"},

Exceptions and Reasons for Upload Operations

[SDriveException]"Parent Folder IDs must be the same for all file records that are being uploaded". 
[Reason] If Parent__c values which are passed in with the SObjects are not same for all S3Object.
[Solution] Give the parent folder ids the same for all S3Objects.

[SDriveException]"A file with the same name exists in the target folder (fileName) ".
[Reason] This exception occurs if a file with the same name exists in the same folder for S3Objects.The same file name condition holds when the file is not a WIP (WIP_c =false) file or the file is a WIP file (WIP_c =true) with the same file namebutithasbeenuploadedbyanotheruserlessthan12 hours ago.
[Solution]Upload files with different file names or delete the previously existing files before the upload.

[SDriveException]"Error occurred while checking the files to upload! File Name, File Size cannot be blank (fileName)".
[Reason]If the file name or file size fields that have been passed in with the SObject are null or empty.
[Solution]File name and file size is required for upload. Thus, pass non-blank values in with the SObject.

[SDriveException]"Name cannot start with a space or a dot and cannot contain any of the following characters: \\ /: ? \" < > |  (fileName)". 
[Reason]If the file name is invalid. Invalid name means, file name starts with a spaceor a dot and contains any of the following characters:  \ / :  ? \" < > | 
[Solution]Do not upload a file with the name starting with space or a dot and contain any of the following characters:  \ / : * ? \" < > | ~

[SDriveException]"You cannot upload a zero-length file (fileName)".  
[Reason] If the file size is 0. 
[Solution] Upload files that are greater in size than zero.

[SDriveException]"Files greater than (maxFileSize) cannot be uploaded. Please contact your system administrator for the file size limits! (fileName)".
[Reason]File being uploaded has a size greater than the maximum file size limit  (MAX_FILE_SIZE configuration in S-Drive Configuration page).
[Solution]Do not upload files whose size greater than MAX_FILE_SIZE. Or Increase the MAX_FILE_SIZE configuration in S-Drive Configuration page.

[SDriveException]"Invalid parent id specified. Check your function parameters!". 
[Reason] If object (parent) id, which is passed as a parameter, is not a 15 or 18 characters long ID.
[Solution]Pass 15-character or ID as objectId parameter.

Error Messagesof ResultObject and Reasons

[errorMessage]"Wip Id is null! ". 
[Reason] If wipId in the wipIds list parameter is null.
[Solution] Do not pass null IDs of file objects.

[errorMessage]"'No such wip file with provided id: (wipId) ".
[Reason]If wipId in wipIds list is not available.
[Solution]Pass correct and available ids of files objects.

[errorMessage]"There is no wip files".
[Reason]If all of wipId in wipIds list is null or wipIds' size is 0.
[Solution]Pass wipIds with length greater than0 and non-null string values.

[errorMessage]" Insufficient Privileges. You do not have not access to update operation".
[Reason]If Object-level security for update access is not allowed.
[Solution] Make sure that update access is allowed for your profile.
Html upload example:

File : <input type="file" name="file" id="file" />
      <input type="button" value="Upload" onclick="htmlUpload();"/>
<script type="text/javascript">

var uploadFile ;

function handleFileSelect(evt)
    var fileName = evt.currentTarget.files[0].name ;
    var fileSize = evt.currentTarget.files[0].size;
    uploadFile = evt.currentTarget.files[0];
    //Call initializeUpload() method

function htmlUpload()
    var fd = new FormData();
    fd.append('key', '{!uploadRequestInfos.fileLocation}');
    fd.append('AWSAccessKeyId', '{!accessKey}');
    fd.append('acl', 'private');
    fd.append('policy', '{!uploadRequestInfos.policy}');
    fd.append('signature', '{!uploadRequestInfos.signature}');
    fd.append('x-amz-server-side-encryption', 'AES256');
    fd.append('Content-Disposition', 'attachment; filename=\"'+
    '{!uploadRequestInfos.fileName}' +'\"');
    var xhr = new XMLHttpRequest();
    xhr.addEventListener("load", htmlUploadComplete, false);
    xhr.addEventListener("error", htmlUploadFailed, false);'POST', ''+'{!bucketName}',
function htmlUploadComplete(evt)
    //Call completeUpload() method
function htmlUploadFailed(evt)
    //Call cancelUpload() method

You can see the appropriate values for the request parameters below (Figure 10).

Form Field



'attachment; filename=\"'+ uploadRequestInfos.fileName+'\"'