终止分段上传

分段上传可以将大文件分割成片段后上传,除了最后一个片段,每个片段的数据大小为5MB~5GB。本文介绍如何列举终止分段上传对象。

接口定义:

void S3_abort_multipart_upload(S3BucketContext *bucketContext, const char *key,
                               const char *uploadId,
                               int timeoutMs,
                               S3AbortMultipartUploadHandler *handler);

参数:

参数名 类型 说明
bucketContext S3BucketContext * 包含bucket及相关的请求参数
key const char * 将要上传的对象的文件名
uploadId const char * S3_initiate_multipart中得到的upload_id
timeoutMs int 如果非0,则是以毫秒为单位的请求超时时间
handler S3AbortMultipartUploadHandler* 回调函数

示例代码:

void abort_multipart_upload(const char *key, const char *upload_id)
{
    S3AbortMultipartUploadHandler abortMultipartUploadHandler =
        {
            {&responsePropertiesCallback, &responseCompleteCallback},
        };

    do
    {
        S3_abort_multipart_upload(&bucketContext, key, upload_id,
                                  0, &abortMultipartUploadHandler);
    } while (S3_status_is_retryable(statusG) && should_retry());

    if (statusG != S3StatusOK)
    {
        printError();
    }
}