S3 ninja emulates the Amazon S3 API for development and test purposes.
See https://s3ninja.net for more details.
To run S3 Ninja using Docker Compose for development:
- Ensure you have Docker and Docker Compose installed.
- From the project root, run:
This will build the image and start the service on port 9444, with data persisted in the
docker-compose up --build./datadirectory.
- Build the image (requires Maven artifacts in
target/):docker build -t s3ninja:local . - Run the container:
docker run --rm -p 9444:9000 -v %cd%/data:/data s3ninja:local- Access the UI at: http://localhost:9444/ui
- S3 API endpoint: http://localhost:9444/
- Mount your local
data/directory to persist buckets and objects across container restarts. - For code changes, rebuild the image after running
mvn clean package -DskipTests.
S3 Ninja supports AWS S3-compatible presigned POST requests for secure file uploads.
Use the built-in tool to generate the required form fields:
mvn -q -Dexec.mainClass=ninja.tools.PresignedPostGenerator exec:java
This outputs the necessary fields: key, policy, x-amz-algorithm, x-amz-credential, x-amz-date, x-amz-signature, and optionally x-amz-security-token if using a session token.
- URL:
POST http://localhost:9444/<bucket>/<key> - Content-Type:
multipart/form-data - Form Fields: Include the generated fields plus the file to upload as
file=@/path/to/file.
Example curl command:
curl -X POST "http://localhost:9444/test/example.txt" \
-F "key=example.txt" \
-F "policy=<BASE64_POLICY>" \
-F "x-amz-algorithm=AWS4-HMAC-SHA256" \
-F "x-amz-credential=<ACCESS_KEY>/<DATE>/<REGION>/s3/aws4_request" \
-F "x-amz-date=<YYYYMMDDTHHMMSSZ>" \
-F "x-amz-signature=<HEX_SIGNATURE>" \
-F "file=@example.txt"
If using a session token (from /session-token endpoint), add:
-F "x-amz-security-token=<SESSION_TOKEN>"
The policy enforces conditions like bucket, key, expiration, and optional security token. On success, the file is uploaded; on failure, an XML error is returned.
Contributions as issues or pull requests are always welcome. Please sign off all your commits by adding a line like "Signed-off-by: Name " at the end of each commit, indicating that you wrote the code and have the right to pass it on as an open source
S3 ninja is licensed under the MIT License:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
