0
namespace gcs = google::cloud::storage;
using ::google::cloud::StatusOr;

auto client_options = 
gcs::ClientOptions::CreateDefaultClientOptions();

auto client = gcs::internal::CurlClient::Create(*client_options);
StatusOr<std::unique_ptr<gcs::internal::ResumableUploadSession>> session;
std::uint64_t total_size = 0;
void performresumableupload(std::string& bucket_name,
                        std::string& object_name,
                        std::string& data, std::uint64_t data_size, bool isFinal) {

gcs::internal::ResumableUploadRequest request(bucket_name, object_name);


StatusOr<gcs::internal::ResumableUploadResponse> response;
total_size += data_size;
if (!isFinal) {
    session = client->CreateResumableSession(request);
    response = (*session)->UploadChunk(data);

}
else {
    std::cout << "Uploading total size " << total_size << "\n";
    response = (*session)->UploadFinalChunk(data, total_size);

}
std::cout << "Response Status: " << response.status() << "\n";
}

I'm using curlclient to upload a huge object in chunks of 5MB (a multiple of 256K) and it works. However, I'd like to be able to Cancel this operation and get rid of the partially uploaded chunks before UploadFinalChunk has been called and the object has been committed. From looking at the documentation here, I see that to cancel the resumable upload request, I would have to send a DELETE request. However, I don't see any method available in the CurlClient that will help me do the same. Appreciate any help.

4

1 回答 1

1

We never implemented an API to to cancel resumable uploads. I just created a feature request #4404, if there is anything you want to add in the GitHub issue please feel free.

Also, I am curious why you are using storage::internal::CurlClient directly? Typically the APIs in storage::Client are more friendly, and as the namespace implies, storage::internal::CurlClient is an internal API, we might change it or remove it without notice. Feel free to contact me directly (my email should be easy to find) if you prefer.

于 2020-06-16T04:51:22.523 回答