S-Drive 3.6 Documentation

initializeMultiPartUpload

Starts a multipart upload for a large file and returns an uploadId you'll pass to every subsequent step. Use this instead of a single direct upload (the default path after initializeUpload) when a file is too large, or the connection too unreliable, to send in one request.

When to use the multipart flow instead of a single upload

Use when a file is large enough that one HTTP request isn't practical, or you'd rather be able to retry a single failed chunk than restart the whole file. The maximum number of parts is 10,000 for S3-backed orgs (check the maxPartCount field on the UploadRequestInfo from initializeUpload — it's different for GCS-backed orgs).

You are here:

initializeUpload → initializeMultiPartUpload → copyPartMultiPartUpload (×N) → completeMultiPartUpload → completeUpload

See Uploading a file end-to-end for the full sequence.

How to call this method

global static String initializeMultiPartUpload(String awsLocation)

global static String initializeMultiPartUpload(String awsLocation, Map<String,String> metadataHeaders)

Parameters

Parameter

Type

Required

Description

awsLocation

String

Yes

The storage key this file will be uploaded to — the fileLocation value returned by initializeUpload for this file.

metadataHeaders

Map<String,String>

No

Extra metadata headers to attach to the object in storage (e.g. custom x-amz-meta-* headers). Pass null if you don't need any.

Return value

Returns the uploadId (a String) for this multipart session. Hold onto it — every remaining step needs it.

Example

UploadRequestInfo info = uploadInfos[0]; // from initializeUpload

String uploadId = SDriveTools.initializeMultiPartUpload(info.fileLocation);
System.debug('Multipart upload started: ' + uploadId);

// Next: upload each chunk of the file and call copyPartMultiPartUpload for each one.