axum-static-s3

Crates.ioaxum-static-s3
lib.rsaxum-static-s3
version0.1.2
created_at2025-05-30 14:51:41.090419+00
updated_at2025-05-30 14:55:27.447713+00
descriptionEasily serve static files from S3 with Axum
homepage
repositoryhttps://github.com/dpruessner/axum-static-s3
max_upload_size
id1695164
size88,023
Daniel Pruessner (dpruessner)

documentation

README

Rust Axum S3 Static

Easily serve S3 content from an Axum Route.

use axum::{Router, routing::get};
use axum_static_s3::S3OriginBuilder;

let s3_origin = S3OriginBuilder::new()
    .bucket("my-bucket")
    .prefix("deploy/")
    .max_size(1024 * 1024 * 12) // 12 MiB
    .build()

let Router = Router::new()
    .nest_service("/static", s3_origin)

Description

In modern webapp development, the back-end may be hosted on a local workstation during development, and a serverless compute environment during deployment. This crate makes it easy to serve S3 resources as a path in an Axum router.

Features

  • Serves static files from AWS S3
  • Compatible with API Gateway -> Lambda back-end, serving front-end resources from S3
    • Can specify response size limits for proper Payload Too Large responses if origin exceeds serverless compute response size
  • Built with Axum web framework
  • Efficient file handling (streams body)
  • Configurable through environment variables

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or contact author directly.

Acknowledgments

Commit count: 4

cargo fmt