Skip to content

FSS3 is an S3 filesystem abstraction layer for Golang

License

Notifications You must be signed in to change notification settings

aymanbagabas/fss3

Repository files navigation

FSS3

Build Status Go version Go Reference Go Report Card GitHub release

FSS3 is an S3 filesystem abstraction layer for Golang that implements most of fs, and io interfaces, and os functions. It is based on minio-go which makes it compatible with any S3 compliant service.

Download

go get github.com/aymanbagabas/fss3

Quick Start

package main

import "github.com/aymanbagabas/fss3"

func main() {
	cfg := fss3.Config{
		AccessKeyID:     "AWS_ACCESS_KEY_ID",
		SecretAccessKey: "AWS_SECRET_ACCESS_KEY",
		Endpoint:        "ENDPOINT",
		UseSSL:          true,
		BucketName:      "MY_BUCKET_NAME",
		Region:          "REGION",
		DirFileName:     "_", // special directory file name that stores directory metadata
		Umask:           0, // Don't set umask
	}
	s3, err := fss3.New(cfg)
	if err != nil {
		panic(err)
	}

	err = s3.Mkdir("Newfolder", 0777)
	if err != nil {
		panic(err)
	}

	data := []byte{"hello world"}
	err = s3.WriteFile("Newfolder/myfile.txt", data, 0644)
	if err != nil {
		panic(err)
	}

	err = s3.RemoveAll("Newfolder")
	if err != nil {
		panic(err)
	}
}

License

This library is distributed under the MIT License, see LICENSE for more information.