feat(s3): preserve Content-Disposition on object responses (#408)

* feat(s3): preserve Content-Disposition on object responses
* fix(s3): preserve Content-Disposition for multipart uploads
* test(s3): avoid duplicate order annotations
This commit is contained in:
sf-jin-ku authored and GitHub committed 2026-04-13 14:18:14 -05:00
1 parent 3621c32b88
commit c8797e2456
6 files changed
+138 -14

No files matched your search

@@ -990,6 +990,100 @@ class S3IntegrationTest {
given().delete("/cache-control-bucket");
}
// --- Content-Disposition header preservation ---
@Test
@Order(130)
void createContentDispositionBucketAndPutObject() {
String disposition = "attachment; filename=\"download.txt\"";
given()
.put("/content-disposition-bucket")
.then()
.statusCode(200);
given()
.contentType("text/plain")
.header("Content-Disposition", disposition)
.body("disposition-content")
.when()
.put("/content-disposition-bucket/disposition.txt")
.then()
.statusCode(200)
.header("ETag", notNullValue());
}
@Test
@Order(131)
void getObjectReturnsContentDisposition() {
given()
.when()
.get("/content-disposition-bucket/disposition.txt")
.then()
.statusCode(200)
.header("Content-Disposition", equalTo("attachment; filename=\"download.txt\""));
}
@Test
@Order(132)
void headObjectReturnsContentDisposition() {
given()
.when()
.head("/content-disposition-bucket/disposition.txt")
.then()
.statusCode(200)
.header("Content-Disposition", equalTo("attachment; filename=\"download.txt\""));
}
@Test
@Order(133)
void copyObjectPreservesContentDisposition() {
given()
.header("x-amz-copy-source", "/content-disposition-bucket/disposition.txt")
.when()
.put("/content-disposition-bucket/disposition-copy.txt")
.then()
.statusCode(200)
.body(containsString("CopyObjectResult"));
given()
.when()
.head("/content-disposition-bucket/disposition-copy.txt")
.then()
.statusCode(200)
.header("Content-Disposition", equalTo("attachment; filename=\"download.txt\""));
}
@Test
@Order(134)
void copyObjectReplaceContentDisposition() {
given()
.header("x-amz-copy-source", "/content-disposition-bucket/disposition.txt")
.header("x-amz-metadata-directive", "REPLACE")
.header("Content-Disposition", "inline; filename=\"inline.txt\"")
.when()
.put("/content-disposition-bucket/disposition-inline.txt")
.then()
.statusCode(200)
.body(containsString("CopyObjectResult"));
given()
.when()
.head("/content-disposition-bucket/disposition-inline.txt")
.then()
.statusCode(200)
.header("Content-Disposition", equalTo("inline; filename=\"inline.txt\""));
}
@Test
@Order(135)
void cleanupContentDispositionBucket() {
given().delete("/content-disposition-bucket/disposition.txt");
given().delete("/content-disposition-bucket/disposition-copy.txt");
given().delete("/content-disposition-bucket/disposition-inline.txt");
given().delete("/content-disposition-bucket");
}
// --- S3 Notification Configuration with Filter ---
@Test
@@ -32,6 +32,7 @@ class S3MultipartIntegrationTest {
.contentType("application/octet-stream")
.header("x-amz-meta-owner", "team-a")
.header("x-amz-storage-class", "STANDARD_IA")
.header("Content-Disposition", "attachment; filename=\"multipart.bin\"")
.when()
.post("/" + BUCKET + "/" + KEY + "?uploads")
.then()
@@ -125,6 +126,7 @@ class S3MultipartIntegrationTest {
.get("/" + BUCKET + "/" + KEY)
.then()
.statusCode(200)
.header("Content-Disposition", equalTo("attachment; filename=\"multipart.bin\""))
.header("x-amz-meta-owner", equalTo("team-a"))
.header("x-amz-storage-class", equalTo("STANDARD_IA"))
.body(equalTo("Part1Data-HelloPart2Data-World"));