You can interrupt an object upload during the upload.

Sample code

The following code provides an example on how to interrupt an object upload:
#include <alibabacloud/oss/OssClient.h>
#include <fstream>
using namespace AlibabaCloud::OSS;

int main(void)
    /* Initialize the information about the account that is used to access Object Storage Service (OSS). */
    /* The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations in OSS is a high-risk operation. We recommend that you use a Resource Access Management (RAM) user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. */
    std::string AccessKeyId = "yourAccessKeyId";
    std::string AccessKeySecret = "yourAccessKeySecret";
    /* Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to */
    std::string Endpoint = "yourEndpoint";
    /* Specify the name of the bucket. Example: examplebucket. */
    std::string BucketName = "examplebucket";

     /* Initialize resources such as networks. */

    ClientConfiguration conf;
    OssClient client(Endpoint, AccessKeyId, AccessKeySecret, conf);
    std::vector<PutObjectOutcomeCallable> Callables;
    for (int i=0; i < 4; i++)  {  
        std::shared_ptr<std::iostream> content = std::make_shared<std::fstream>("yourLocalFilename", std::ios::in|std::ios::binary);
        PutObjectRequest request(BucketName, ObjectName, content);
        auto outcomeCallable = client.PutObjectCallable(request);

    /* Interrupt the upload. */

    for (size_t i = 0; i < Callables.size(); i++) {
        auto outcome = Callables[i].get();
        if (outcome.error().Code() == "ClientError:100002" ||
        outcome.error().Code() == "ClientError:200042") {
            std::cout << "disable putobject success" << std::endl;

    /* Release resources such as networks. */
    return 0;
Note The operation to interrupt an object upload and the operation to cancel a multipart upload have the following differences:
  • If you interrupt an object upload, the upload API call is stopped. In other words, you canceled the upload task. If you cancel a multipart upload, OSS stops processing the multipart upload task with the upload ID.
  • If you interrupt a multipart upload task, the task is canceled, but you can still use the upload ID to upload an object. If you cancel a multipart upload task, the upload ID is unavailable for future uploads.
  • The operation to interrupt an object upload takes effect on all API operations. The operation to cancel a multipart upload takes effect only on the multipart upload.