Update readme and docstrings, minor refactors.

This commit is contained in:
Rohan Verma
2018-12-24 17:31:36 +05:30
parent d218b23f05
commit e4c7d93da1
4 changed files with 150 additions and 30 deletions
+31 -7
View File
@@ -2,7 +2,7 @@
## 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)
SimpleS3 is a golang library for uploading and deleting objects on S3 buckets using the REST API calls signed using AWS Signature Version 4
SimpleS3 is a golang library for uploading and deleting objects on S3 buckets using REST API calls or Presigned URLs signed using AWS Signature Version 4.
## Install
@@ -16,7 +16,16 @@ go get github.com/rhnvrm/simples3
testTxt, _ := os.Open("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)
// File Upload is as simple as providing the following
// details.
err := s3.FileUpload(simples3.UploadInput{
Bucket: AWSBucket,
ObjectKey: "test.txt",
@@ -24,19 +33,34 @@ err := s3.FileUpload(simples3.UploadInput{
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 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: "examplebucket",
ObjectKey: "test.txt",
Method: "GET",
Timestamp: time,
ExpirySeconds: 86400,
})
```
## Contributing
ToDo.
## Contributors
ToDo.
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
ToDo.
Rohan Verma <hello@rohanverma.net>
## License