Cancels an in-progress multipart upload session on the storage bucket side — freeing the parts already sent for that uploadId. This is the multipart counterpart to cancelUpload, but the two don't overlap: this method never touches the Salesforce WIP record, it only cancels the session in storage.
Use it when a multipart upload (started with initializeMultiPartUpload) stalls or fails partway through — a chunk PUT fails repeatedly, the client gives up, the user cancels — and you want to abandon the session rather than resume it.
How to call this method
global static void abortMultiPartUpload(String awsLocation, String uploadId)
Parameters
|
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
|
|
Yes |
The file's storage key — the same |
|
|
|
Yes |
The multipart session Id returned by |
Return value
None — this method returns void. There's no ResultObject, no confirmation payload. Success is simply "it didn't throw."
Error behavior
-
If the upload you’re trying to abort doesn’t exist (it actually completed, you sent the wrong id, etc), no exception is thrown.
-
All other errors messages will throw an
SDriveExceptionwith that message.
In practice, that means calling abortMultiPartUpload on a session that's already gone succeeds silently, exactly like aborting one that was genuinely still in progress. It's safe to call this defensively (e.g. in a cleanup path where you're not sure whether the upload already completed), but the lack of an exception doesn't tell you whether you actually cancelled something or just no-opped.
⚠ Before you call this
-
This only affects the storage-side session. The Salesforce WIP record is untouched — pair this with
cancelUploadif you also want that record removed. -
This does not clean up temporary chunk objects.
copyPartMultiPartUploadworks by first PUTting each chunk's bytes to a temporary key (fileLocation.0,fileLocation.1, …) and then copying that object into the multipart session as a registered part. Aborting the session cancels the session's own bookkeeping and whatever parts were already registered into it — but the temporary key objects are separate, standalone objects in the bucket, not "parts" in the storage backend's own accounting, and this method has no effect on them. UsedeleteMultiPartsfor those. A full cleanup of a stalled multipart upload is three calls, not one:abortMultiPartUpload(session),deleteMultiParts(temp chunk objects), andcancelUpload(the WIP record) — see Canceling an upload end-to-end.
Example
try {
SDriveTools.abortMultiPartUpload(info.fileLocation, uploadId);
} catch (SDriveException e) {
// A real failure to abort — not just "already gone"
System.debug(LoggingLevel.ERROR, 'Failed to abort multipart upload: ' + e.getMessage());
}
// Still need to clean up the Salesforce side separately:
List<ResultObject> results = SDriveTools.cancelUpload(
new List<Id>{ info.wipFileId },
caseId
);