Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(s3): allow upload up to 512MB by default. close #19 (#110)

Hector Ventura38912326c967
diff --git a/docs/configuration/application-yml.md b/docs/configuration/application-yml.md
index 2885f12c77..47a5f07e9e 100644
--- a/docs/configuration/application-yml.md
+++ b/docs/configuration/application-yml.md
@@ -9,6 +9,7 @@ floci:
base-url: "http://localhost:4566" # Used to build callback URLs (e.g. SNS subscription endpoints)
default-region: us-east-1
default-account-id: "000000000000"
+ max-request-size: 512 # Max HTTP request body size in MB (default 512 MB)
auth:
validate-signatures: false # Set to true to enforce AWS request signing
@@ -136,6 +137,7 @@ floci:
| `FLOCI_SERVICES_SQS_DEFAULT_VISIBILITY_TIMEOUT` | `30` | Visibility timeout (seconds) |
| `FLOCI_SERVICES_SQS_MAX_MESSAGE_SIZE` | `262144` | Max message size (bytes) |
| `FLOCI_SERVICES_SQS_MAX_RECEIVE_COUNT` | `10` | Max receive count |
+| `FLOCI_MAX_REQUEST_SIZE` | `512` | Max HTTP request body size in MB |
| `FLOCI_SERVICES_S3_MAX_MULTIPART_PARTS` | `10000` | Max parts per upload |
| `FLOCI_SERVICES_S3_DEFAULT_PRESIGN_EXPIRY_SECONDS` | `3600` | Pre-signed URL expiry |
| `FLOCI_SERVICES_DYNAMODB_MAX_ITEM_SIZE` | `400000` | Max item size (bytes) |
diff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
index 88c27d1b4b..4ab2a1c970 100644
--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
@@ -38,6 +38,9 @@ public interface EmulatorConfig {
@WithDefault("000000000000")
String defaultAccountId();
+ @WithDefault("512")
+ int maxRequestSize();
+
StorageConfig storage();
AuthConfig auth();
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 2954972dc8..f1c071a376 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -3,7 +3,7 @@ quarkus:
port: 4566
host: 0.0.0.0
limits:
- max-body-size: 256M
+ max-body-size: ${floci.max-request-size}M
native:
additional-build-args: >-
--initialize-at-run-time=org.apache.hc.client5.http.impl.auth.NTLMEngineImpl,
@@ -16,6 +16,7 @@ quarkus:
--initialize-at-run-time=io.github.hectorvent.floci.services.acm.CertificateGenerator
floci:
+ max-request-size: 512
base-url: "http://localhost:4566"
# hostname: "" # When set, overrides the hostname in response URLs (e.g. SQS QueueUrl).
# Needed for multi-container Docker setups. Example: FLOCI_HOSTNAME=floci
diff --git a/src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java
index 82a1c246b2..ec27cc05b2 100644
--- a/src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java
@@ -6,6 +6,8 @@ import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
+import java.util.Arrays;
+
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.*;
@@ -434,7 +436,7 @@ class S3IntegrationTest {
}
@Test
- @Order(15)
+ @Order(16)
void getObjectAttributesRejectsUnknownSelector() {
given()
.header("x-amz-object-attributes", "ETag,UnknownThing")
@@ -446,6 +448,7 @@ class S3IntegrationTest {
}
@Test
+ @Order(17)
void getNonExistentBucket() {
given()
.when()
@@ -534,4 +537,37 @@ class S3IntegrationTest {
.statusCode(400)
.body(containsString("InvalidLocationConstraint"));
}
+
+ @Test
+ @Order(20)
+ void putLargeObject() {
+ // 22 MB – exceeds the old Jackson 20 MB maxStringLength default
+ byte[] largeBody = new byte[22 * 1024 * 1024];
+ Arrays.fill(largeBody, (byte) 'A');
+
+ given()
+ .when()
+ .put("/large-object-bucket")
+ .then()
+ .statusCode(200);
+
+ given()
+ .contentType("application/octet-stream")
+ .body(largeBody)
+ .when()
+ .put("/large-object-bucket/large-file.bin")
+ .then()
+ .statusCode(200)
+ .header("ETag", notNullValue());
+
+ given()
+ .when()
+ .get("/large-object-bucket/large-file.bin")
+ .then()
+ .statusCode(200)
+ .header("Content-Length", String.valueOf(largeBody.length));
+
+ given().delete("/large-object-bucket/large-file.bin");
+ given().delete("/large-object-bucket");
+ }
}
diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml
index b445106642..591746108a 100644
--- a/src/test/resources/application.yml
+++ b/src/test/resources/application.yml
@@ -2,6 +2,8 @@ quarkus:
http:
port: 0
test-port: 0
+ limits:
+ max-body-size: ${floci.max-request-size}M
floci:
base-url: "http://localhost:4566"