/go-filestorage

Golang package for file storage

Primary LanguageGoMIT LicenseMIT

go-filestorage

Golang package for file storage

Requirements

  • Go >= 1.10

Installation

go get github.com/ramadani/go-filestorage

Usage

import storage "github.com/ramadani/go-filestorage"

config := &storage.Config{
	Root: "storage",
	URL:  "http://yourdomain.com/public",
}

localStorage := storage.NewStorage(config)

Store the file to the storage

localStorage.PutFile("user", file)

It will be create a new user dir if not exists and then store the file into that.

Store the file to the storage with specifying a file name

localStorage.PutFileAs("user", file, "user1.jpeg")

Check file or directory is exists or not

isFileExists := localStorage.Exists("user/user1.jpeg")
// true

isDirExists := localStorage.Exists("product")
// false

Get url of the file

url := localStorage.URL("user/user1.jpeg")
// http://yourdomain.com/public/user/user1.jpeg

License

The go-filestorage is an open-source software licensed under the MIT License.