Before you upload an object to Object Storage Service (OSS) by using resumable upload, you can specify a folder for the checkpoint file that stores resumable upload records. If an object fails to upload because the network is abnormal or the program stops responding, the upload task is resumed from the position recorded in the checkpoint file to upload the remaining bytes.

The progress of the current upload is recorded in the checkpoint file during the upload process. If a part fails to be uploaded during the process, the next upload attempt starts from the recorded position in the checkpoint file. The checkpoint file is deleted after the resumable upload task is completed.
Note For the complete code that is used to perform resumable upload, visit GitHub.

The following code provides an example on how to perform resumable upload by using multipart upload:

using Aliyun.OSS;
using Aliyun.OSS.Common;

// Set yourEndpoint to the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set yourEndpoint to 
var endpoint = "yourEndpoint";
// Security risks may arise if you use the AccessKey pair of an Alibaba Cloud account to access OSS because the account has permissions on all API operations. 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. 
var accessKeyId = "yourAccessKeyId";
var accessKeySecret = "yourAccessKeySecret";
// Specify the name of the bucket to which you want to upload the object. Example: examplebucket. 
var bucketName = "examplebucket";
// Specify the full path of the object. Example: exampledir/exampleobject.txt. The full path of the object cannot contain the bucket name. 
var objectName = "exampledir/exampleobject.txt";
// Specify the full path of the local file to upload. Example: D:\\localpath\\examplefile.txt. 
// By default, if you specify only the name of the local file such as examplefile.txt without specifying the local path, the local file is uploaded from the path of the project to which the sample program belongs. 
var localFilename = "D:\\localpath\\examplefile.txt";
// Specify the checkpoint file that records the upload result of each part. The file stores the progress information generated in the upload process. 
string checkpointDir = "yourCheckpointDir";
// Create an OSSClient instance. 
var client = new OssClient(endpoint, accessKeyId, accessKeySecret);
    // Configure parameters by using UploadFileRequest. 
    UploadObjectRequest request = new UploadObjectRequest(bucketName, objectName, localFilename)
        // Specify the size of each part to upload. 
        PartSize = 8 * 1024 * 1024,
        // Specify the number of concurrent threads. 
        ParallelThreadCount = 3,
        // Set the checkpointDir parameter to store the state of the resumable upload, which is used to resume the upload when the upload fails. 
        // If you set checkpointDir to null, resumable upload does not take effect and the object is uploaded again when it fails to be uploaded. 
        CheckpointDir = checkpointDir,
    // Start resumable upload. 
    Console.WriteLine("Resumable upload object:{0} succeeded", objectName);
catch (OssException ex)
    Console.WriteLine("Failed with error code: {0}; Error info: {1}. \nRequestID:{2}\tHostID:{3}",
        ex.ErrorCode, ex.Message, ex.RequestId, ex.HostId);
catch (Exception ex)
    Console.WriteLine("Failed with error info: {0}", ex.Message);