s3-micro icon indicating copy to clipboard operation
s3-micro copied to clipboard

This project is an upload and download microservice of Amazon S3.

S3 microservice

This project is an upload and download microservice of Amazon S3.

Build Status GitHub release Go Report Card GoDoc MIT License HitCount

[ English | 中文 ]

Table of Contents

  • Installation
  • Configuration
  • Build
    • Run Grpc Server
    • Run Http Server
  • Usage
    • RESTful API examples
    • Grpc examples
  • Features
  • Swagger
  • Support and Feedback
  • Contact
  • License

Installation

Use go get to retrieve the project to add it to your GOPATH workspace, or project's Go module dependencies.

go get github.com/lxlxw/s3-micro

To update the project use go get -u to retrieve the latest version of the project.

go get -u github.com/lxlxw/s3-micro

Configuration

cat ./conf/s3.toml
[S3]
accesskey = "AKIAJCWZ4372EFTEW6ZA"
secretkey = "xxxxxx"
region = "us-east-1"
endpoint = "s3.amazonaws.com"

Build

$ cd "$GOPATH/src/github.com/lxlxw/s3-micro"
make build

Run Grpc Server

make server

Run Http Server

make http

Usage

RESTful API examples

curl -X POST -k http://localhost:8088/api/object/upload -d '{"bucketname": "test_bucket", "key":"test/test.txt", "filecontent":"xxxxxx"}'

You find more detailed api documentation at /doc.

or

open http://localhost:8088/swagger-ui

Grpc examples

create a service client, make a request, handle the error, and process the response.

package main

import (
	"log"

	"golang.org/x/net/context"
	"google.golang.org/grpc"

	pb "github.com/lxlxw/s3-micro/proto"
)

func main() {

	conn, err := grpc.Dial(":50052", grpc.WithInsecure())
	if err != nil {
		log.Println(err)
	}
	defer conn.Close()

	// new client
	c := pb.NewStoreApiServiceClient(conn)

	// call method
	req := &pb.CreateBucketRequest{Bucketname: "test-bucket"}
	res, err := c.CreateBucket(context.Background(), req)
	if err != nil {
		log.Println(err)
	}
	log.Println(res.Msg)
}

Features

  • gRPC
  • RESTful API
  • Swagger UI
  • Middleware
  • App configurable
  • Logging
  • JWT Authorization

Swagger

Support and Feedback

If you find a bug, please submit the issue in Github directly. S3-Micro Issues

Contact

License

S3-Micro is based on the MIT protocol.

http://www.opensource.org/licenses/MIT