local

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2024 License: MIT Imports: 9 Imported by: 5

README

gFly Storage

Usage

Install

# Storage
go get -u github.com/gflydev/storage@v1.0.0

# Local Storage
go get -u github.com/gflydev/storage/local@v1.0.0

Quick usage main.go

import (
    "github.com/gflydev/core"
    "github.com/gflydev/storage"
    // Auto initial local storage
    _ "github.com/gflydev/storage/local"	
)

func main() {
    // Create file storage with default
    fs := storage.Instance()

	// Create folder `foo/bar` and add file `hello.txt`
    if ok := fs.MakeDir("foo/bar"); ok {
        fs.Put("foo/bar/hello.txt", "Hello world")
    }
}

Documentation

Index

Constants

View Source
const (
	Type = storage.Type("local")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalStorage

type LocalStorage struct {
	BaseDir string
}

func New

func New() *LocalStorage

New Create local storage.

func (*LocalStorage) Append

func (s *LocalStorage) Append(path, data string) bool

func (*LocalStorage) Copy

func (s *LocalStorage) Copy(from, to string) bool

func (*LocalStorage) Delete

func (s *LocalStorage) Delete(path string) bool

func (*LocalStorage) DeleteDir

func (s *LocalStorage) DeleteDir(dir string) bool

func (*LocalStorage) Exists

func (s *LocalStorage) Exists(path string) bool

func (*LocalStorage) Get

func (s *LocalStorage) Get(path string) ([]byte, error)

func (*LocalStorage) LastModified

func (s *LocalStorage) LastModified(path string) time.Time

func (*LocalStorage) MakeDir

func (s *LocalStorage) MakeDir(dir string) bool

func (*LocalStorage) Move

func (s *LocalStorage) Move(from, to string) bool

func (*LocalStorage) Path

func (s *LocalStorage) Path(path string) string

Path Create file by content

func (*LocalStorage) Put

func (s *LocalStorage) Put(path, contents string, options ...interface{}) bool

Put Create file by content

func (*LocalStorage) PutData

func (s *LocalStorage) PutData(path string, contents []byte) bool

PutData Create file by content

func (*LocalStorage) PutFile

func (s *LocalStorage) PutFile(path string, fileSource *os.File, options ...interface{}) bool

func (*LocalStorage) Size

func (s *LocalStorage) Size(path string) int64

func (*LocalStorage) Url

func (s *LocalStorage) Url(path string) string

Url Get public URL of an object via path

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL