ws3

package module
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 15 Imported by: 2

README

gFly Wasabi Storage

https://docs.wasabi.com/docs/how-do-i-use-aws-sdk-for-go-golang-with-wasabi

Usage

Install

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

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

Quick usage main.go

import (
    "github.com/gflydev/core"
    "github.com/gflydev/storage"
    storageWS3 "github.com/gflydev/storage/ws3"	
)

func main() {
    // Register WS3 storage
    storage.Register(storageWS3.Type, storageWS3.New())

    // Create S3 storage with default
    fs := storage.Instance(storageWS3.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")
    }
}
WS3 setting

Make sure WS3 below setting:

Section Bucket policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicRead",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject",
                "s3:PutObject",
                "s3:DeleteObject",
                "s3:PutObjectAcl",
                "s3:GetObjectAcl",
                "s3:GetObjectAttributes"
            ],
            "Resource": "arn:aws:s3:::gfly-local/*"
        }
    ]
}

Section Cross-origin resource sharing (CORS)

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT",
            "POST",
            "DELETE"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": []
    }
]

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

type Storage struct {
	S3Client *minio.Client
}

func New

func New() *Storage

New Create S3 Storage with basics info.

func (*Storage) Append

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

func (*Storage) Copy

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

func (*Storage) Delete

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

func (*Storage) DeleteDir

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

func (*Storage) Exists

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

func (*Storage) Get

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

func (*Storage) GetStream added in v1.1.7

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

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

func (*Storage) MakeDir

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

func (*Storage) Move

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

func (*Storage) Put

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

func (*Storage) PutData

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

PutData Create file by content

func (*Storage) PutFile

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

func (*Storage) PutFilepath

func (s *Storage) PutFilepath(path, filePath string, options ...interface{}) bool

func (*Storage) Size

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

func (*Storage) Url

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

Url Get public URL of an object via path Pattern URL `https://s3.<region>.wasabisys.com/<bucket>/<key>`

Jump to

Keyboard shortcuts

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