To be compatible with aws s3, an x-amz-version-id header should be returned.
For atomic upload, RGWPutObj::version_id will stores the version-id either
generated by rgw randomly or read from user. For multipart upload,
RGWCompleteMultipart::version_id will stores the version-id either
generated by rgw randomly or read from user.
Function send_respones() will send 'x-amz-version-id' header when version_id is not empty.
Signed-off-by: Xinying Song <songxinying@cloudin.cn>
(cherry picked from commit
b4a937562a7ae909c2748980b5327189ccb8cdc0)
instance = i;
}
+ const string& get_instance() const {
+ return instance;
+ }
+
string get_index_key_name() const {
if (ns.empty()) {
if (name.size() < 1 || name[0] != '_') {
(delete_at ? *delete_at : real_time()), if_match, if_nomatch,
(user_data.empty() ? nullptr : &user_data));
+ // only atomic upload will upate version_id here
+ if (!multipart)
+ version_id = (static_cast<RGWPutObjProcessor_Atomic *>(processor))->get_version_id();
+
/* produce torrent */
if (s->cct->_conf->rgw_torrent_flag && (ofs == torrent.get_data_len()))
{
RGWMPObj mp;
RGWObjManifest manifest;
uint64_t olh_epoch = 0;
- string version_id;
op_ret = get_params();
if (op_ret < 0)
target_obj.init(s->bucket, s->object.name);
if (versioned_object) {
- store->gen_rand_obj_instance_name(&target_obj);
+ if (!version_id.empty()) {
+ target_obj.key.set_instance(version_id);
+ } else {
+ store->gen_rand_obj_instance_name(&target_obj);
+ version_id = target_obj.key.get_instance();
+ }
}
RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
protected:
string upload_id;
string etag;
+ string version_id;
char *data;
int len;
return r;
}
- if (!version_id.empty()) {
- head_obj.key.set_instance(version_id);
- } else if (versioned_object) {
- store->gen_rand_obj_instance_name(&head_obj);
+ if (versioned_object) {
+ if (!version_id.empty()) {
+ head_obj.key.set_instance(version_id);
+ } else {
+ store->gen_rand_obj_instance_name(&head_obj);
+ version_id = head_obj.key.get_instance();
+ }
}
manifest.set_trivial_rule(max_chunk_size, store->ctx()->_conf->rgw_obj_stripe_size);
void set_version_id(const string& vid) {
version_id = vid;
}
+
+ const string& get_version_id() const {
+ return version_id;
+ }
}; /* RGWPutObjProcessor_Atomic */
#define MP_META_SUFFIX ".meta"
dump_errno(s);
dump_etag(s, etag);
dump_content_length(s, 0);
+ dump_header_if_nonempty(s, "x-amz-version-id", version_id);
for (auto &it : crypt_http_responses)
dump_header(s, it.first, it.second);
} else {
dump_errno(s);
+ dump_header_if_nonempty(s, "x-amz-version-id", version_id);
end_header(s, this, "application/xml");
dump_start(s);
struct tm tmp;
if (op_ret)
set_req_state_err(s, op_ret);
dump_errno(s);
+ dump_header_if_nonempty(s, "x-amz-version-id", version_id);
end_header(s, this, "application/xml");
if (op_ret == 0) {
dump_start(s);