Golang's http.FileSystem Implementation for AWS S3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
505 B

package s3fs
import (
"net/http"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/s3"
)
// New for getting a new s3FileSystem object
func New(bucket, prefix string) (http.FileSystem, error) {
initSVC()
_, err := s3svc.HeadBucket(&s3.HeadBucketInput{
Bucket: aws.String(bucket),
})
if err != nil {
return nil, err
}
return s3FileSystem{
bucket: bucket,
prefix: prefix,
}, nil
}
func (fs s3FileSystem) Open(key string) (http.File, error) {
return fs.NewFile(key)
}