Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cpp/src/arrow/filesystem/s3fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,7 @@ std::shared_ptr<const KeyValueMetadata> GetObjectMetadata(const ObjectResult& re

md->Append("Content-Length", ToChars(result.GetContentLength()));
push("Cache-Control", result.GetCacheControl());
push("Content-Encoding", result.GetContentEncoding());
push("Content-Type", result.GetContentType());
push("Content-Language", result.GetContentLanguage());
push("ETag", result.GetETag());
Expand All @@ -1319,6 +1320,7 @@ struct ObjectMetadataSetter {
static std::unordered_map<std::string, Setter> GetSetters() {
return {{"ACL", CannedACLSetter()},
{"Cache-Control", StringSetter(&ObjectRequest::SetCacheControl)},
{"Content-Encoding", ContentEncodingSetter()},
{"Content-Type", ContentTypeSetter()},
{"Content-Language", StringSetter(&ObjectRequest::SetContentLanguage)},
{"Expires", DateTimeSetter(&ObjectRequest::SetExpires)}};
Expand Down Expand Up @@ -1359,6 +1361,13 @@ struct ObjectMetadataSetter {
};
}

static Setter ContentEncodingSetter() {
return [](const std::string& str, ObjectRequest* req) {
req->SetContentEncoding(str);
return Status::OK();
};
}

static Result<S3Model::ObjectCannedACL> ParseACL(const std::string& v) {
if (v.empty()) {
return S3Model::ObjectCannedACL::NOT_SET;
Expand Down
10 changes: 6 additions & 4 deletions cpp/src/arrow/filesystem/s3fs_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1532,8 +1532,9 @@ TEST_F(TestS3FS, OpenOutputStreamMetadata) {
testing::IsSupersetOf(implicit_metadata->sorted_pairs()));

// Create new file with explicit metadata
auto metadata = KeyValueMetadata::Make({"Content-Type", "Expires"},
{"x-arrow/test6", "2016-02-05T20:08:35Z"});
auto metadata = KeyValueMetadata::Make(
{"Content-Encoding", "Content-Type", "Expires"},
{"gzip", "x-arrow/test6", "2016-02-05T20:08:35Z"});
AssertMetadataRoundtrip("bucket/mdfile1", metadata,
testing::IsSupersetOf(metadata->sorted_pairs()));

Expand All @@ -1543,8 +1544,9 @@ TEST_F(TestS3FS, OpenOutputStreamMetadata) {
AssertMetadataRoundtrip("bucket/mdfile2", metadata, testing::_);

// Create new file with default metadata
auto default_metadata = KeyValueMetadata::Make({"Content-Type", "Content-Language"},
{"image/png", "fr_FR"});
auto default_metadata = KeyValueMetadata::Make(
{"Content-Encoding", "Content-Type", "Content-Language"},
{"br", "image/png", "fr_FR"});
options_.default_metadata = default_metadata;
MakeFileSystem();
// (null, then empty metadata argument)
Expand Down