This Rust-based gRPC service allows you to stream a file to an S3-compatible storage, such as MinIO, by specifying a tenant, which maps to an S3 bucket. The service only allows you to upload one file at a time.
- File Upload: Stream a file to the service using gRPC. The file is uploaded to the specified S3 bucket (identified by the
tenant
metadata). - gRPC Service: Uses
tonic
for the gRPC implementation. - S3 Integration: Integrates with S3-compatible storage services using
rusoto_s3
.
-
Clone the repository:
git clone https://github.com/bennekrouf/s3-connector.git cd s3-connector
-
Set up the necessary environment variables in a
.env
file:P_S3_URL=http://localhost:9000 P_S3_ACCESS_KEY=minioadmin P_S3_SECRET_KEY=minioadmin P_S3_REGION=us-east-1
-
Run the server:
cargo run
The server will start listening on
[::1]:50051
.
- tenant: The tenant identifier (maps to the S3 bucket).
- filename: The name of the file being uploaded.
You can use grpcurl
to interact with the gRPC service. Here's an example of uploading a file using grpcurl
:
-
Create a file to upload:
echo "Hello, gRPC!" > test_file.txt
-
Use
grpcurl
to upload the file in a streaming manner:grpcurl -plaintext \ -d @ \ -rpc-header "tenant:minio-bucket" \ -rpc-header "filename:test_file.txt" \ 0.0.0.0:50051 minioc.MiniocService/streamUpload < test_file.txt
This will stream the contents of test_file.txt
to the gRPC server, and the file will be uploaded to the S3 bucket named minio-bucket
.
Ensure the following environment variables are set in your .env
file:
P_S3_URL
: The URL of your S3-compatible service (e.g., MinIO).P_S3_ACCESS_KEY
: The access key for S3.P_S3_SECRET_KEY
: The secret key for S3.P_S3_REGION
: The region for S3 (for MinIO, this is usuallyus-east-1
).
This project is licensed under the MIT License.