From a44a2c2430423e6ad15281e0dd307e4fc760bfe7 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Mon, 19 Sep 2016 12:28:08 +0200 Subject: [PATCH] rgw: add support for object prefixes in Swift's FormPost. Signed-off-by: Radoslaw Zarzynski --- src/rgw/rgw_rest_swift.cc | 14 ++++++++++++-- src/rgw/rgw_rest_swift.h | 6 +++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 3cc5994ed699e..f0069700463bc 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -1714,6 +1714,16 @@ bool RGWInfo_ObjStore_SWIFT::is_expired(const std::string& expires, CephContext* } +void RGWFormPost::init(RGWRados* const store, + req_state* const s, + RGWHandler* const dialect_handler) +{ + prefix = std::move(s->object.name); + s->object = rgw_obj_key(); + + return RGWPostObj_ObjStore::init(store, s, dialect_handler); +} + int RGWFormPost::get_params() { /* The parentt class extracts boundary info from the Content-Type. */ @@ -1792,13 +1802,13 @@ std::string RGWFormPost::get_current_filename() const const auto iter = field.params.find("filename"); if (std::end(field.params) != iter) { - return s->object.name + iter->second; + return prefix + iter->second; } } catch (std::out_of_range&) { /* NOP */; } - return s->object.name; + return prefix; } bool RGWFormPost::is_next_file_to_upload() diff --git a/src/rgw/rgw_rest_swift.h b/src/rgw/rgw_rest_swift.h index 26524af303222..6572034a87c77 100644 --- a/src/rgw/rgw_rest_swift.h +++ b/src/rgw/rgw_rest_swift.h @@ -243,13 +243,17 @@ class RGWFormPost : public RGWPostObj_ObjStore { bool is_next_file_to_upload() override; boost::optional current_data_part; - + std::string prefix; bool stream_done = false; public: RGWFormPost() = default; ~RGWFormPost() = default; + void init(RGWRados* store, + req_state* s, + RGWHandler* dialect_handler) override; + int get_params() override; int get_data(ceph::bufferlist& bl) override; void send_response() override; -- 2.39.5