triple-s
(Simple Storage Service) is a simplified version of Amazon S3, designed to provide a REST API for managing storage buckets and objects. This project demonstrates key concepts of RESTful API design, basic networking, and data management, providing a practical foundation for understanding cloud storage solutions.
- Bucket Management: Create, list, and delete storage buckets.
- Object Management: Upload, retrieve, and delete objects within buckets.
- Metadata Handling: Store and manage object metadata in CSV files.
- REST API: Interact with the storage system using HTTP methods.
- XML Responses: All API responses conform to the Amazon S3 XML format.
- HTTP Method:
PUT
- Endpoint:
/{BucketName}
- Request Body: Empty
- Behavior:
- Validate bucket name.
- Ensure bucket name is unique.
- Create a new bucket.
- Respond with
200 OK
or an appropriate error message.
- HTTP Method:
GET
- Endpoint:
/
- Behavior:
- List all existing buckets.
- Respond with
200 OK
and bucket details.
- HTTP Method:
DELETE
- Endpoint:
/{BucketName}
- Behavior:
- Validate bucket existence.
- Delete the bucket.
- Respond with
204 No Content
or an appropriate error message.
- HTTP Method:
PUT
- Endpoint:
/{BucketName}/{ObjectKey}
- Request Body: Binary data of the object
- Headers:
Content-Type
: The object's data type.Content-Length
: The length of the content in bytes.
- Behavior:
- Validate bucket and object key.
- Save the object content.
- Store object metadata.
- Respond with
200 OK
or an appropriate error message.
- HTTP Method:
GET
- Endpoint:
/{BucketName}/{ObjectKey}
- Behavior:
- Validate bucket and object existence.
- Return the object data or an error.
- HTTP Method:
DELETE
- Endpoint:
/{BucketName}/{ObjectKey}
- Behavior:
- Validate bucket and object existence.
- Delete the object and update metadata.
- Respond with
204 No Content
or an appropriate error message.
Each bucket has its own object metadata CSV file (e.g., data/{bucket-name}/objects.csv
).
- Columns:
ObjectKey
: The unique key of the object.Size
: The size of the object in bytes.ContentType
: The MIME type of the object.LastModified
: The timestamp of the last modification.
To run the triple-s
project, you can use the provided Makefile
for convenience. Follow these steps:
-
Clone the Repository:
gh repo clone ab-dauletkhan/triple-s cd triple-s
-
Build the Project:
make build
-
Run the Project:
./triple-s # it will run on default port: 8080 and directory: ./data # to specify subcommands ./triple-s --port=8080 --dir="./data" # or ./triple-s --help
build
: Compiles the project.run
: Runs the project with specified default flags (port: 8080, dir: "./data"
)format
: Formats the project with gofumpt