From: Radoslaw Zarzynski Date: Wed, 21 Sep 2016 13:53:55 +0000 (+0200) Subject: rgw: RGWFormPost does support Swift's max_file_size parameter. X-Git-Tag: v12.0.3~99^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8a46d071bc12877ad6bfcda3ad42fc871cb1fb93;p=ceph.git rgw: RGWFormPost does support Swift's max_file_size parameter. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 49655cbea318..cd6444c4a4b4 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -1724,6 +1724,23 @@ void RGWFormPost::init(RGWRados* const store, return RGWPostObj_ObjStore::init(store, s, dialect_handler); } +std::size_t RGWFormPost::get_max_file_size() /*const*/ +{ + std::string max_str = get_part_str(ctrl_parts, "max_file_size", "0"); + + std::string err; + const std::size_t max_file_size = + static_cast(strict_strtoll(max_str.c_str(), 10, &err)); + + if (! err.empty()) { + ldout(s->cct, 5) << "failed to parse FormPost's max_file_size: " << err + << dendl; + return 0; + } + + return max_file_size; +} + bool RGWFormPost::is_non_expired() { std::string expires = get_part_str(ctrl_parts, "expires", "0"); @@ -1847,6 +1864,9 @@ int RGWFormPost::get_params() } } while (! stream_done); + min_len = 0; + max_len = get_max_file_size(); + if (! current_data_part) { err_msg = "FormPost: no files to process"; return -EINVAL; diff --git a/src/rgw/rgw_rest_swift.h b/src/rgw/rgw_rest_swift.h index 78d772103882..8032bcf656f6 100644 --- a/src/rgw/rgw_rest_swift.h +++ b/src/rgw/rgw_rest_swift.h @@ -242,6 +242,7 @@ public: class RGWFormPost : public RGWPostObj_ObjStore { std::string get_current_filename() const override; + std::size_t get_max_file_size() /*const*/; bool is_next_file_to_upload() override; bool is_integral(); bool is_non_expired();