mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(s3): persist x-amz-meta-* metadata from presigned POST uploads (#727)
This commit is contained in:
1 parent
9c3f263aa0
commit
692d665734
2 files changed
+48
-1
No files matched your search
+35
@@ -476,6 +476,40 @@ class S3PresignedPostIntegrationTest {
|
||||
.header("ETag", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(97)
|
||||
void presignedPostPersistsUserMetadata() {
|
||||
String key = "uploads/with-metadata.txt";
|
||||
String fileContent = "metadata test";
|
||||
|
||||
String policy = buildPolicy(BUCKET, key, "text/plain", 0, 10485760);
|
||||
String policyBase64 = Base64.getEncoder().encodeToString(policy.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
given()
|
||||
.multiPart("key", key)
|
||||
.multiPart("Content-Type", "text/plain")
|
||||
.multiPart("policy", policyBase64)
|
||||
.multiPart("x-amz-algorithm", "AWS4-HMAC-SHA256")
|
||||
.multiPart("x-amz-credential", "AKIAIOSFODNN7EXAMPLE/20260330/us-east-1/s3/aws4_request")
|
||||
.multiPart("x-amz-date", AMZ_DATE_FORMAT.format(Instant.now()))
|
||||
.multiPart("x-amz-signature", "dummysignature")
|
||||
.multiPart("x-amz-meta-source", "camera")
|
||||
.multiPart("x-amz-meta-owner", "test-user")
|
||||
.multiPart("file", "with-metadata.txt", fileContent.getBytes(StandardCharsets.UTF_8), "text/plain")
|
||||
.when()
|
||||
.post("/" + BUCKET)
|
||||
.then()
|
||||
.statusCode(204);
|
||||
|
||||
given()
|
||||
.when()
|
||||
.head("/" + BUCKET + "/" + key)
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("x-amz-meta-source", equalTo("camera"))
|
||||
.header("x-amz-meta-owner", equalTo("test-user"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(100)
|
||||
void cleanupBucket() {
|
||||
@@ -487,6 +521,7 @@ class S3PresignedPostIntegrationTest {
|
||||
given().delete("/" + BUCKET + "/uploads/within-range.txt");
|
||||
given().delete("/" + BUCKET + "/uploads/prefix-test.txt");
|
||||
given().delete("/" + BUCKET + "/uploads/capital-p-ok.txt");
|
||||
given().delete("/" + BUCKET + "/uploads/with-metadata.txt");
|
||||
|
||||
given()
|
||||
.when()
|
||||
|
||||
Reference in new issue
Block a user