This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new c03b6eb1cb ARROW-16043: [C++][Filesystem][S3] Add missing empty 
content for creating directory
c03b6eb1cb is described below

commit c03b6eb1cb167cceb5aec850bb233ffaa1e0ce14
Author: Sutou Kouhei <[email protected]>
AuthorDate: Sat Apr 16 05:23:45 2022 +0900

    ARROW-16043: [C++][Filesystem][S3] Add missing empty content for creating 
directory
    
    We can't omit body to create a directory.
    
    Closes #12895 from kou/cpp-s3-create-directory
    
    Authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/src/arrow/filesystem/s3fs.cc      | 1 +
 cpp/src/arrow/filesystem/s3fs_test.cc | 1 +
 2 files changed, 2 insertions(+)

diff --git a/cpp/src/arrow/filesystem/s3fs.cc b/cpp/src/arrow/filesystem/s3fs.cc
index 28017cad7e..91d4359012 100644
--- a/cpp/src/arrow/filesystem/s3fs.cc
+++ b/cpp/src/arrow/filesystem/s3fs.cc
@@ -1702,6 +1702,7 @@ class S3FileSystem::Impl : public 
std::enable_shared_from_this<S3FileSystem::Imp
     S3Model::PutObjectRequest req;
     req.SetBucket(ToAwsString(bucket));
     req.SetKey(ToAwsString(key));
+    req.SetBody(std::make_shared<std::stringstream>(""));
     return OutcomeToStatus(
         std::forward_as_tuple("When creating key '", key, "' in bucket '", 
bucket, "': "),
         client_->PutObject(req));
diff --git a/cpp/src/arrow/filesystem/s3fs_test.cc 
b/cpp/src/arrow/filesystem/s3fs_test.cc
index 9e63d548a3..98ee30e848 100644
--- a/cpp/src/arrow/filesystem/s3fs_test.cc
+++ b/cpp/src/arrow/filesystem/s3fs_test.cc
@@ -418,6 +418,7 @@ class TestS3FS : public S3TestMixin {
       Aws::S3::Model::PutObjectRequest req;
       req.SetBucket(ToAwsString("bucket"));
       req.SetKey(ToAwsString("emptydir/"));
+      req.SetBody(std::make_shared<std::stringstream>(""));
       ASSERT_OK(OutcomeToStatus(client_->PutObject(req)));
       // NOTE: no need to create intermediate "directories" somedir/ and
       // somedir/subdir/

Reply via email to