local

package module
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 10 Imported by: 5

README

gFly Local Storage

Usage

Install

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

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

Quick usage main.go

import (
    "github.com/gflydev/core"
    "github.com/gflydev/storage"
    storageLocal "github.com/gflydev/storage/local"	
)

func main() {
    // Register Local storage
    storage.Register(storageLocal.Type, storageLocal.New())

    // Create file storage with default
    fs := storage.Instance(storageLocal.Type)

	// 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 Storage added in v1.1.0

type Storage struct {
	BaseDir string
}

func New

func New() *Storage

New Create local storage.

func (*Storage) Append added in v1.1.0

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

func (*Storage) Copy added in v1.1.0

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

func (*Storage) Delete added in v1.1.0

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

func (*Storage) DeleteDir added in v1.1.0

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

func (*Storage) Exists added in v1.1.0

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

func (*Storage) Get added in v1.1.0

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

func (*Storage) GetStream added in v1.1.6

func (s *Storage) GetStream(path string) (io.ReadCloser, error)

GetStream returns a stream (io.ReadCloser) for the object at the given path This allows for efficient streaming without loading the entire file into memory

func (*Storage) LastModified added in v1.1.0

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

func (*Storage) MakeDir added in v1.1.0

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

func (*Storage) Move added in v1.1.0

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

func (*Storage) Path added in v1.1.0

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

Path Create file by content

func (*Storage) Put added in v1.1.0

func (s *Storage) Put(path, contents string) bool

Put Create file by content

func (*Storage) PutData added in v1.1.0

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

PutData Create file by content

func (*Storage) PutFile added in v1.1.0

func (s *Storage) PutFile(path string, fileSource *os.File) bool

func (*Storage) Size added in v1.1.0

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

func (*Storage) Url added in v1.1.0

func (s *Storage) 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