S3-at-Home is a simplified, local version of Amazon S3, implemented in Go. It provides a basic object storage system with a RESTful API, allowing you to store and retrieve objects using a bucket/key structure.
- NoSQL database backend (Redis) for storing objects and metadata
- Bucket management (creation, deletion, listing)
- Object operations (upload, download, delete)
- RESTful API for interacting with the storage system
- CORS support for web applications
- Go 1.16 or higher
- Redis server
-
Clone the repository:
git clone https://github.com/yourusername/s3-at-home.git cd s3-at-home
-
Install dependencies:
go mod download
-
Build the application:
go build ./cmd/server
The application uses environment variables for configuration:
SERVER_ADDR
: The address and port the server will listen on (default: ":8080")REDIS_ADDR
: The address of your Redis server (default: "localhost:6379")
You can set these environment variables before running the server, for example:
export SERVER_ADDR=":3000"
export REDIS_ADDR="localhost:6379"
-
Start the Redis server.
-
Run the S3-at-Home server:
./server
-
The server will start and listen for requests on the specified port (default: 8080).
GET /
: List all bucketsPUT /:bucket
: Create a new bucketDELETE /:bucket
: Remove a bucketGET /:bucket
: List objects in a bucketPUT /:bucket/:object
: Upload an objectGET /:bucket/:object
: Download an objectDELETE /:bucket/:object
: Remove an object
Here are some example curl commands to interact with the API:
-
Create a bucket:
curl -X PUT http://localhost:8080/my-bucket
-
Upload an object:
curl -X PUT -H "Content-Type: text/plain" --data-binary "Hello, S3!" http://localhost:8080/my-bucket/hello.txt
-
Download an object:
curl http://localhost:8080/my-bucket/hello.txt
-
List buckets:
curl http://localhost:8080/
-
List objects in a bucket:
curl http://localhost:8080/my-bucket
-
Delete an object:
curl -X DELETE http://localhost:8080/my-bucket/hello.txt
-
Delete a bucket:
curl -X DELETE http://localhost:8080/my-bucket
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.