You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
List Objects
List Multipart Uploads (C++ SDK)
Copy page
Download PDF
List Multipart Uploads (C++ SDK)
This article presents key considerations and sample code for listing multipart uploads.​
Precautions​
  • To list multipart uploads, you must have the tos:ListBucketMultipartUploads permission for the bucket. For detailed instructions, refer to the IAM policy overview.​
  • This list pertains to ongoing multipart upload tasks with unmerged parts. If a multipart upload task has already had its parts merged, that task will no longer be listed.​
Parameters​
​
Parameter​
Description​
delimiter​
A character used to group object names.​
encodingType​
Encode the returned content and specify the type of encoding.​
Default value: None​
maxUploads​
Returns the maximum number of multipart upload tasks. The default value is 1000.​
Value range: greater than 0 and less than or equal to 1000.​
prefix​
Used to specify the prefix for objects returned by listing.​
keyMarker​
List the starting positions of multipart upload tasks. Return a list of objects sorted alphabetically, starting after the specified value. This is typically the nextMarker value returned by the previous request.​
uploadIdMarker​
Used in conjunction with keyMarker, this parameter specifies that the multipart upload task list will be returned in dictionary order starting from the value following keyMarker. Obtain nextVersionIdMarker from the results of the previous listing.​
​
Sample code​
Briefly list incomplete multipart uploads​
The following code is used to list 10 incomplete multipart uploads in the specified bucket.​
​
#include "TosClientV2.h"​
using namespace VolcengineTos;​
​
int main(void){​
​
​
std::string region = "Your Region";​
std::string accessKey = std::getenv("TOS_ACCESS_KEY");​
std::string secretKey = std::getenv("TOS_SECRET_KEY");​
​
std::string bucketName = "examplebucket";​
​
​
InitializeClient();​
​
TosClientV2 client(region, accessKey, secretKey);​
​
​
ListMultipartUploadsV2Input input(bucketName);​
​
input.setMaxUploads(10);​
auto output = client.listMultipartUploads(input);​
if (!output.isSuccess()) {​
​
std::cout << "ListMultipartUploads failed." << output.error().String() << std::endl;​
​
CloseClient();​
return -1;​
}​
std::cout << "ListMultipartUploads success." << std::endl;​
for (const auto& part : output.result().getUploads()) {​
std::cout << "part"<<​
",key:" << part.getKey() <<​
",uploadId:" << part.getUploadId() <<​
",storageClasss:" << part.getStringFormatStorageClass() <<​
",initiated time:" << part.getStringFormatInitiated() << std::endl;​
}​
​
CloseClient();​
return 0;​
}​
​
List all incomplete multipart uploads with the specified prefix​
The following code is used to list all incomplete multipart uploads under the specified prefix in the designated bucket.​
​
#include "TosClientV2.h"​
using namespace VolcengineTos;​
​
int main(void){​
​
​
std::string region = "Your Region";​
std::string accessKey = std::getenv("TOS_ACCESS_KEY");​
std::string secretKey = std::getenv("TOS_SECRET_KEY");​
​
std::string bucketName = "examplebucket";​
​
std::string prefix = "yourkeyPrefix";​
​
InitializeClient();​
​
TosClientV2 client(region, accessKey, secretKey);​
​
ListMultipartUploadsV2Input input(bucketName);​
​
input.setPrefix(prefix);​
​
input.setMaxUploads(100);​
​
bool isTruncated = true;​
std::string nextKeyMarker = "";​
while(isTruncated){​
input.setKeyMarker(nextKeyMarker);​
auto output = client.listMultipartUploads(input);​
if (!output.isSuccess()) {​
​
std::cout << "ListMultipartUploads failed." << output.error().String() << std::endl;​
​
CloseClient();​
return -1;​
}​
​
nextKeyMarker = output.result().getNextKeyMarker();​
isTruncated = output.result().isTruncated();​
​
std::cout << "ListMultipartUploads success." << std::endl;​
for (const auto& part : output.result().getUploads()) {​
std::cout << "part"<<​
",key:" << part.getKey() <<​
",uploadId:" << part.getUploadId() <<​
",storageClasss:" << part.getStringFormatStorageClass() <<​
",initiated time:" << part.getStringFormatInitiated() << std::endl;​
}​
}​
​
​
CloseClient();​
return 0;​
}​
​
List all multipart uploads​
The following code is used to list all incomplete multipart uploads in the specified bucket.​
​
#include "TosClientV2.h"​
using namespace VolcengineTos;​
​
int main(void){​
​
​
std::string region = "Your Region";​
std::string accessKey = std::getenv("TOS_ACCESS_KEY");​
std::string secretKey = std::getenv("TOS_SECRET_KEY");​
​
std::string bucketName = "examplebucket";​
​
​
InitializeClient();​
​
TosClientV2 client(region, accessKey, secretKey);​
​
ListMultipartUploadsV2Input input(bucketName);​
​
input.setMaxUploads(100);​
​
bool isTruncated = true;​
std::string nextKeyMarker = "";​
while(isTruncated){​
input.setKeyMarker(nextKeyMarker);​
auto output = client.listMultipartUploads(input);​
if (!output.isSuccess()) {​
​
std::cout << "ListMultipartUploads failed." << output.error().String() << std::endl;​
​
CloseClient();​
return -1;​
}​
​
nextKeyMarker = output.result().getNextKeyMarker();​
isTruncated = output.result().isTruncated();​
​
std::cout << "ListMultipartUploads success." << std::endl;​
for (const auto& part : output.result().getUploads()) {​
std::cout << "part"<<​
",key:" << part.getKey() <<​
",uploadId:" << part.getUploadId() <<​
",storageClasss:" << part.getStringFormatStorageClass() <<​
",initiated time:" << part.getStringFormatInitiated() << std::endl;​
}​
}​
​
​
CloseClient();​
return 0;​
}​
​
Recursively list incomplete multipart uploads​
TOS only uses the object model. To simulate directory functionality, create a zero-byte object that ends with a forward slash (/).​
The functionality of a directory can be simulated using the delimiter and prefix parameters:​
  1. First, set the delimiter to/When prefix is also set to empty, objects and subdirectory information under the root directory can be returned.​
  1. Set delimiter again to/By simultaneously setting prefix as a subdirectory (subfiledir), objects and subdirectories of the subdirectory can be returned.​
The following code recursively lists incomplete multipart uploads in the bucket 'examplebucket' by directory.​
​
#include "TosClientV2.h"​
using namespace VolcengineTos;​
​
int main(void){​
​
​
std::string region = "Your Region";​
std::string accessKey = std::getenv("TOS_ACCESS_KEY");​
std::string secretKey = std::getenv("TOS_SECRET_KEY");​
​
std::string bucketName = "examplebucket";​
​
​
InitializeClient();​
​
TosClientV2 client(region, accessKey, secretKey);​
​
​
ListMultipartUploadsV2Input input(bucketName);​
​
input.setDelimiter("/");​
​
input.setMaxUploads(100);​
auto output = client.listMultipartUploads(input);​
if (!output.isSuccess()) {​
​
std::cout << "ListMultipartUploads failed." << output.error().String() << std::endl;​
​
CloseClient();​
return -1;​
}​
​
std::cout << "ListMultipartUploads success." << std::endl;​
for (const auto& part : output.result().getUploads()) {​
std::cout << "part"<<​
",key:" << part.getKey() <<​
",uploadId:" << part.getUploadId() <<​
",storageClasss:" << part.getStringFormatStorageClass() <<​
",initiated time:" << part.getStringFormatInitiated() << std::endl;​
}​
for (const auto& prefix : output.result().getCommonPrefixes()) {​
std::cout << "Sub Dir:"<< prefix.getPrefix() << std::endl;​
}​
​
CloseClient();​
return 0;​
}​
​
Relevant documentation​
For API documentation on listing multipart uploads, see ListMultipartUploads.​
Last updated: 2026.08.03 10:23:28