| 1635 | } |
| 1636 | |
| 1637 | ACTOR static Future<std::string> beginMultiPartUpload_impl(Reference<S3BlobStoreEndpoint> bstore, |
| 1638 | std::string bucket, |
| 1639 | std::string object) { |
| 1640 | wait(bstore->requestRateWrite->getAllowance(1)); |
| 1641 | |
| 1642 | std::string resource = constructResourcePath(bstore, bucket, object); |
| 1643 | resource += "?uploads"; |
| 1644 | HTTP::Headers headers; |
| 1645 | if (!CLIENT_KNOBS->BLOBSTORE_ENCRYPTION_TYPE.empty()) |
| 1646 | headers["x-amz-server-side-encryption"] = CLIENT_KNOBS->BLOBSTORE_ENCRYPTION_TYPE; |
| 1647 | Reference<HTTP::Response> r = wait(bstore->doRequest("POST", resource, headers, nullptr, 0, { 200 })); |
| 1648 | |
| 1649 | try { |
| 1650 | xml_document<> doc; |
| 1651 | // Copy content because rapidxml will modify it during parse |
| 1652 | std::string content = r->content; |
| 1653 | |
| 1654 | doc.parse<0>((char*)content.c_str()); |
| 1655 | |
| 1656 | // There should be exactly one node |
| 1657 | xml_node<>* result = doc.first_node(); |
| 1658 | if (result != nullptr && strcmp(result->name(), "InitiateMultipartUploadResult") == 0) { |
| 1659 | xml_node<>* id = result->first_node("UploadId"); |
| 1660 | if (id != nullptr) { |
| 1661 | return id->value(); |
| 1662 | } |
| 1663 | } |
| 1664 | } catch (...) { |
| 1665 | } |
| 1666 | throw http_bad_response(); |
| 1667 | } |
| 1668 | |
| 1669 | Future<std::string> S3BlobStoreEndpoint::beginMultiPartUpload(std::string const& bucket, std::string const& object) { |
| 1670 | return beginMultiPartUpload_impl(Reference<S3BlobStoreEndpoint>::addRef(this), bucket, object); |
nothing calls this directly
no test coverage detected