[bug] S3 provider should limit max key size to 1024 #31
This commit is contained in:
		| @@ -128,22 +128,22 @@ auto s3_provider::create_directory_impl(const std::string &api_path, | |||||||
|       utils::path::create_api_path(is_encrypted ? meta[META_KEY] : api_path); |       utils::path::create_api_path(is_encrypted ? meta[META_KEY] : api_path); | ||||||
|  |  | ||||||
|   std::string response_data; |   std::string response_data; | ||||||
|   curl::requests::http_put_file put_file{}; |   curl::requests::http_put_file put_dir{}; | ||||||
|   put_file.allow_timeout = true; |   put_dir.allow_timeout = true; | ||||||
|   put_file.aws_service = "aws:amz:" + cfg.region + ":s3"; |   put_dir.aws_service = "aws:amz:" + cfg.region + ":s3"; | ||||||
|   put_file.response_handler = [&response_data](auto &&data, |   put_dir.response_handler = [&response_data](auto &&data, | ||||||
|  |  | ||||||
|                                               long /*response_code*/) { |                                               long /*response_code*/) { | ||||||
|     response_data = std::string(data.begin(), data.end()); |     response_data = std::string(data.begin(), data.end()); | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   auto res = set_request_path(put_file, cfg, object_name + '/'); |   auto res = set_request_path(put_dir, cfg, object_name + '/'); | ||||||
|   if (res != api_error::success) { |   if (res != api_error::success) { | ||||||
|     return res; |     return res; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   long response_code{}; |   long response_code{}; | ||||||
|   if (not get_comm().make_request(put_file, response_code, stop_requested)) { |   if (not get_comm().make_request(put_dir, response_code, stop_requested)) { | ||||||
|     utils::error::raise_api_path_error(function_name, api_path, |     utils::error::raise_api_path_error(function_name, api_path, | ||||||
|                                        api_error::comm_error, |                                        api_error::comm_error, | ||||||
|                                        "failed to create directory"); |                                        "failed to create directory"); | ||||||
| @@ -236,15 +236,15 @@ auto s3_provider::create_path_directories(const std::string &api_path, | |||||||
|  |  | ||||||
|       if (not exists) { |       if (not exists) { | ||||||
|         std::string response_data; |         std::string response_data; | ||||||
|         curl::requests::http_put_file put_file{}; |         curl::requests::http_put_file put_dir{}; | ||||||
|         put_file.allow_timeout = true; |         put_dir.allow_timeout = true; | ||||||
|         put_file.aws_service = "aws:amz:" + cfg.region + ":s3"; |         put_dir.aws_service = "aws:amz:" + cfg.region + ":s3"; | ||||||
|         put_file.response_handler = [&response_data](auto &&data, |         put_dir.response_handler = [&response_data](auto &&data, | ||||||
|                                                     long /*response_code*/) { |                                                     long /*response_code*/) { | ||||||
|           response_data = std::string(data.begin(), data.end()); |           response_data = std::string(data.begin(), data.end()); | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|         res = set_request_path(put_file, cfg, |         res = set_request_path(put_dir, cfg, | ||||||
|                                (is_encrypted ? cur_key : cur_path) + '/'); |                                (is_encrypted ? cur_key : cur_path) + '/'); | ||||||
|         if (res != api_error::success) { |         if (res != api_error::success) { | ||||||
|           return res; |           return res; | ||||||
| @@ -252,7 +252,7 @@ auto s3_provider::create_path_directories(const std::string &api_path, | |||||||
|  |  | ||||||
|         stop_type stop_requested{false}; |         stop_type stop_requested{false}; | ||||||
|         long response_code{}; |         long response_code{}; | ||||||
|         if (not get_comm().make_request(put_file, response_code, |         if (not get_comm().make_request(put_dir, response_code, | ||||||
|                                         stop_requested)) { |                                         stop_requested)) { | ||||||
|           utils::error::raise_api_path_error( |           utils::error::raise_api_path_error( | ||||||
|               function_name, cur_path, api_error::comm_error, |               function_name, cur_path, api_error::comm_error, | ||||||
| @@ -683,7 +683,7 @@ auto s3_provider::get_object_info(bool directory, const std::string &api_path, | |||||||
|                                              long /*response_code*/) { |                                              long /*response_code*/) { | ||||||
|       response_data = std::string(data.begin(), data.end()); |       response_data = std::string(data.begin(), data.end()); | ||||||
|     }; |     }; | ||||||
|     res = set_request_path(put_file, cfg, |     res = set_request_path(head, cfg, | ||||||
|                            directory ? object_name + '/' : object_name); |                            directory ? object_name + '/' : object_name); | ||||||
|     if (res != api_error::success) { |     if (res != api_error::success) { | ||||||
|       return res; |       return res; | ||||||
| @@ -939,21 +939,22 @@ auto s3_provider::remove_directory_impl(const std::string &api_path) | |||||||
|       utils::path::create_api_path(is_encrypted ? key : api_path); |       utils::path::create_api_path(is_encrypted ? key : api_path); | ||||||
|  |  | ||||||
|   std::string response_data; |   std::string response_data; | ||||||
|   curl::requests::http_delete del{}; |   curl::requests::http_delete del_dir{}; | ||||||
|   del.allow_timeout = true; |   del_dir.allow_timeout = true; | ||||||
|   del.aws_service = "aws:amz:" + cfg.region + ":s3"; |   del_dir.aws_service = "aws:amz:" + cfg.region + ":s3"; | ||||||
|   del.response_handler = [&response_data](auto &&data, long /*response_code*/) { |   del_dir.response_handler = [&response_data](auto &&data, | ||||||
|  |                                               long /*response_code*/) { | ||||||
|     response_data = std::string(data.begin(), data.end()); |     response_data = std::string(data.begin(), data.end()); | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   auto res = set_request_path(del, cfg, object_name + '/'); |   auto res = set_request_path(del_dir, cfg, object_name + '/'); | ||||||
|   if (res != api_error::success) { |   if (res != api_error::success) { | ||||||
|     return res; |     return res; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   long response_code{}; |   long response_code{}; | ||||||
|   stop_type stop_requested{}; |   stop_type stop_requested{}; | ||||||
|   if (not get_comm().make_request(del, response_code, stop_requested)) { |   if (not get_comm().make_request(del_dir, response_code, stop_requested)) { | ||||||
|     utils::error::raise_api_path_error(function_name, api_path, |     utils::error::raise_api_path_error(function_name, api_path, | ||||||
|                                        api_error::comm_error, |                                        api_error::comm_error, | ||||||
|                                        "failed to remove directory"); |                                        "failed to remove directory"); | ||||||
| @@ -990,20 +991,21 @@ auto s3_provider::remove_file_impl(const std::string &api_path) -> api_error { | |||||||
|       utils::path::create_api_path(is_encrypted ? key : api_path); |       utils::path::create_api_path(is_encrypted ? key : api_path); | ||||||
|  |  | ||||||
|   std::string response_data; |   std::string response_data; | ||||||
|   curl::requests::http_delete del{}; |   curl::requests::http_delete del_file{}; | ||||||
|   del.allow_timeout = true; |   del_file.allow_timeout = true; | ||||||
|   del.aws_service = "aws:amz:" + cfg.region + ":s3"; |   del_file.aws_service = "aws:amz:" + cfg.region + ":s3"; | ||||||
|   del.response_handler = [&response_data](auto &&data, long /*response_code*/) { |   del_file.response_handler = [&response_data](auto &&data, | ||||||
|  |                                                long /*response_code*/) { | ||||||
|     response_data = std::string(data.begin(), data.end()); |     response_data = std::string(data.begin(), data.end()); | ||||||
|   }; |   }; | ||||||
|   auto res = set_request_path(del, cfg, object_name); |   auto res = set_request_path(del_file, cfg, object_name); | ||||||
|   if (res != api_error::success) { |   if (res != api_error::success) { | ||||||
|     return res; |     return res; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   long response_code{}; |   long response_code{}; | ||||||
|   stop_type stop_requested{}; |   stop_type stop_requested{}; | ||||||
|   if (not get_comm().make_request(del, response_code, stop_requested)) { |   if (not get_comm().make_request(del_file, response_code, stop_requested)) { | ||||||
|     utils::error::raise_api_path_error(function_name, api_path, |     utils::error::raise_api_path_error(function_name, api_path, | ||||||
|                                        api_error::comm_error, |                                        api_error::comm_error, | ||||||
|                                        "failed to remove file"); |                                        "failed to remove file"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user