Registers one uploaded chunk ("part") as part of an in-progress multipart upload, and returns that part's ETag — a value you must collect for every part and later hand to completeMultiPartUpload.
This method does not transfer your file's bytes for you. Before calling it for a given part, your code must first upload that chunk's raw bytes to a temporary storage key — conventionally <fileLocation>.<partNumber - 1> — with a direct HTTP PUT. This method then folds that already-uploaded chunk into the multipart upload. If you call this method without having PUT the bytes first, there's nothing to copy in and the part will be empty.
You are here:
initializeUpload → initializeMultiPartUpload → copyPartMultiPartUpload (×N) → completeMultiPartUpload → completeUpload
See Uploading a file end-to-end for a complete walkthrough, including the PUT step this method depends on.
How to call this method
global static String copyPartMultiPartUpload(String awsLocation, String uploadId, Long partNumber)
global static HTTPResponse copyPartMultiPartUploadResponse(String awsLocation, String uploadId, Long partNumber)
copyPartMultiPartUpload returns just the ETag string; copyPartMultiPartUploadResponse returns the raw HTTPResponse if you need more than the ETag (e.g. for troubleshooting a failed part).
Parameters
|
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
|
|
Yes |
The file's storage key (the |
|
|
|
Yes |
The value returned by |
|
|
|
Yes |
Which part this is, starting at 1 (not 0). This must match the number you used when naming the temporary chunk key — note the off-by-one: part 1 is uploaded to a key ending in |
Return value
Returns the ETag (String) the storage service assigned to this part. Keep a list of every part's (partNumber, eTag) pair — completeMultiPartUpload needs the full ordered list.
Before you call this
-
Every part except the last must meet the storage backend's minimum part size (5 MB for S3) — a part that's too small, other than the final one, will be rejected when you try to complete the upload.
-
Upload each chunk's bytes to its temporary key before calling this method for that part.
Example
String uploadId = SDriveTools.initializeMultiPartUpload(info.fileLocation);
List<String> partETags = new List<String>();
Integer partNumber = 1;
for (Blob chunk : fileChunks) { // however you've split the file client-side
String tempKey = info.fileLocation + '.' + (partNumber - 1);
// 1. Upload this chunk's raw bytes to the temporary key yourself (direct PUT, not shown here)
// 2. Then register it as this part of the multipart upload:
String eTag = SDriveTools.copyPartMultiPartUpload(info.fileLocation, uploadId, partNumber);
partETags.add(eTag);
partNumber++;
}
// Next: SDriveTools.completeMultiPartUpload(info.fileLocation, uploadId, partETags);