A secure API for user authentication and S3 file uploads built with Rust, Axum, and Diesel.
Register a new user account
{
"email": "user@example.com",
"password": "securepassword123"
}
{
"user_id": "550e8400-e29b-41d4-a716-446655440000",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}
Authenticate with existing credentials
{
"email": "user@example.com",
"password": "securepassword123"
}
{
"user_id": "550e8400-e29b-41d4-a716-446655440000",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}
You can test these endpoints using curl:
curl -X POST http://localhost:3000/register \
-H "Content-Type: application/json" \
-d '{"email": "test@example.com", "password": "password123"}'
curl -X POST http://localhost:3000/login \
-H "Content-Type: application/json" \
-d '{"email": "test@example.com", "password": "password123"}'
Generate presigned URLs for batch file uploads to S3
{
"files": [
{
"client_path": "Music/track01.mp3",
"size": 7340032,
"content_type": "audio/mpeg",
"checksum_sha256": "optional-base64url",
"last_modified": 1731000000000
}
],
"multipart_threshold_bytes": 5242880,
"part_size_bytes": 8388608
}
{
"entries": [
{
"upload_id": "uuid",
"s3_key": "uploads/user/2024/12/01/uuid_track01.mp3",
"mode": "single",
"put_url": "https://bucket.s3.amazonaws.com/...presigned...",
"ttl_seconds": 1800,
"headers": {
"Content-Type": "audio/mpeg",
"x-amz-meta-client-path": "Music/track01.mp3"
}
}
]
}
Complete a file upload and finalize multipart uploads if applicable
{
"file": {
"upload_id": "uuid",
"s3_key": "uploads/.../track01.mp3",
"mode": "single",
"etag": "\"2f8c...\""
}
}
{
"file": {
"upload_id": "uuid",
"s3_key": "uploads/.../bigfile.wav",
"mode": "multipart",
"aws_upload_id": "aws-upload-id",
"parts": [
{ "part_number": 1, "etag": "\"etag1\"" }
]
}
}
{ "ok": true }
Abort an in-progress multipart upload
{
"upload_id": "uuid",
"s3_key": "uploads/.../bigfile.wav",
"aws_upload_id": "aws-upload-id"
}
{ "ok": true }