Skip to content

Commit a1fc751

Browse files
committed
Update mime types to add gz and gzip extensions
1 parent ba04474 commit a1fc751

File tree

2 files changed

+23
-0
lines changed
  • core/sdk-core/src/main/resources/software/amazon/awssdk/core/util
  • services/s3/src/test/java/software/amazon/awssdk/services/s3/internal/handlers

2 files changed

+23
-0
lines changed

core/sdk-core/src/main/resources/software/amazon/awssdk/core/util/mime.types

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ application/font-tdpfr pfr
3737
application/gml+xml gml
3838
application/gpx+xml gpx
3939
application/gxf gxf
40+
application/gzip gz
41+
application/gzip gzip
4042
application/hyperstudio stk
4143
application/inkml+xml ink inkml
4244
application/ipfix ipfix

services/s3/src/test/java/software/amazon/awssdk/services/s3/internal/handlers/PutObjectHeaderTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,27 @@ public void putObjectFile_headerShouldContainContentType() throws IOException {
8484
verify(putRequestedFor(anyUrl()).withHeader(CONTENT_TYPE, equalTo("text/html")));
8585
}
8686

87+
@Test
88+
public void putObject_gzipFile_hasProperContentType() throws IOException {
89+
File file = new RandomTempFile("test.gz", 10);
90+
stubFor(any(urlMatching(".*"))
91+
.willReturn(response()));
92+
s3Client.putObject(putObjectRequest, RequestBody.fromFile(file));
93+
verify(putRequestedFor(anyUrl()).withHeader(CONTENT_TYPE, equalTo("application/gzip")));
94+
}
95+
96+
@Test
97+
public void putObject_gzipFile_shouldNotOverrideContentTypeInRequest() throws IOException {
98+
File file = new RandomTempFile("test.gz", 10);
99+
String contentType = "something";
100+
stubFor(any(urlMatching(".*"))
101+
.willReturn(response()));
102+
103+
s3Client.putObject(putObjectRequest.toBuilder().contentType(contentType).build(),
104+
RequestBody.fromFile(file));
105+
verify(putRequestedFor(anyUrl()).withHeader(CONTENT_TYPE, equalTo(contentType)));
106+
}
107+
87108
@Test
88109
public void putObjectUnknownFileExtension_contentTypeDefaultToBeStream() throws IOException {
89110
File file = new RandomTempFile("test.unknown", 10);

0 commit comments

Comments
 (0)