Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rhnvrm/simples3
Simple no frills AWS S3 Golang Library using REST with V4 Signing (without AWS Go SDK)
https://github.com/rhnvrm/simples3
aws aws-s3 aws-signature-v4 golang
Last synced: about 13 hours ago
JSON representation
Simple no frills AWS S3 Golang Library using REST with V4 Signing (without AWS Go SDK)
- Host: GitHub
- URL: https://github.com/rhnvrm/simples3
- Owner: rhnvrm
- License: other
- Created: 2018-12-06T10:24:21.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-07-09T07:07:37.000Z (6 months ago)
- Last Synced: 2024-10-14T09:52:34.266Z (2 months ago)
- Topics: aws, aws-s3, aws-signature-v4, golang
- Language: Go
- Homepage:
- Size: 75.2 KB
- Stars: 152
- Watchers: 3
- Forks: 29
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - simples3 - Simple no frills AWS S3 Library using REST with V4 Signing written in Go. (Third-party APIs / Utility/Miscellaneous)
- awesome-go-extra - simples3 - 12-06T10:24:21Z|2022-07-11T05:35:26Z| (Third-party APIs / Fail injection)
README
# simples3 : Simple no frills AWS S3 Library using REST with V4 Signing
## Overview [![GoDoc](https://godoc.org/github.com/rhnvrm/simples3?status.svg)](https://godoc.org/github.com/rhnvrm/simples3) [![Go Report Card](https://goreportcard.com/badge/github.com/rhnvrm/simples3)](https://goreportcard.com/report/github.com/rhnvrm/simples3) [![GoCover](https://gocover.io/_badge/github.com/rhnvrm/simples3)](https://gocover.io/_badge/github.com/rhnvrm/simples3) [![Zerodha Tech](https://zerodha.tech/static/images/github-badge.svg)](https://zerodha.tech)
SimpleS3 is a Go library for manipulating objects
in S3 buckets using REST API calls or Presigned URLs signed
using AWS Signature Version 4.## Install
```sh
go get github.com/rhnvrm/simples3
```## Example
```go
testTxt, _ := os.Open("testdata/test.txt")
defer testTxt.Close()// Create an instance of the package
// You can either create by manually supplying credentials
// (preferably using Environment vars)
s3 := simples3.New(Region, AWSAccessKey, AWSSecretKey)
// or you can use this on an EC2 instance to
// obtain credentials from IAM attached to the instance.
s3, _ := simples3.NewUsingIAM(Region)// You can also set a custom endpoint to a compatible s3 instance.
s3.SetEndpoint(CustomEndpoint)// Note: Consider adding a testTxt.Seek(0, 0)
// in case you have read
// the body, as the pointer is shared by the library.// File Upload is as simple as providing the following
// details.
resp, err := s3.FileUpload(simples3.UploadInput{
Bucket: AWSBucket,
ObjectKey: "test.txt",
ContentType: "text/plain",
FileName: "test.txt",
Body: testTxt,
})// Similarly, Files can be deleted.
err := s3.FileDelete(simples3.DeleteInput{
Bucket: os.Getenv("AWS_S3_BUCKET"),
ObjectKey: "test.txt",
})// You can also download the file.
file, _ := s3.FileDownload(simples3.DownloadInput{
Bucket: AWSBucket,
ObjectKey: "test.txt",
})data, _ := ioutil.ReadAll(file)
file.Close()// You can also use this library to generate
// Presigned URLs that can for eg. be used to
// GET/PUT files on S3 through the browser.
var time, _ = time.Parse(time.RFC1123, "Fri, 24 May 2013 00:00:00 GMT")url := s.GeneratePresignedURL(PresignedInput{
Bucket: AWSBucket,
ObjectKey: "test.txt",
Method: "GET",
Timestamp: time,
ExpirySeconds: 86400,
})
```## Contributing
You are more than welcome to contribute to this project. Fork and make
a Pull Request, or create an Issue if you see any problem or want to
propose a feature.## Author
Rohan Verma
## License
BSD-2-Clause-FreeBSD