]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: RGWFormPost does support Swift's max_file_size parameter.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 21 Sep 2016 13:53:55 +0000 (15:53 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 24 Apr 2017 15:32:16 +0000 (17:32 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_rest_swift.cc
src/rgw/rgw_rest_swift.h

index 49655cbea31846cb5d533ebc8dd45c6bf727500f..cd6444c4a4b422a05856a5c2bc8f1e14953def8c 100644 (file)
@@ -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<uint64_t>(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;
index 78d7721038826eee4f35af2a08359b1dfdfff598..8032bcf656f6ad401ae44557f8413b62ae3747ca 100644 (file)
@@ -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();