storage

package
v0.0.0-...-cf413bb Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright (C) 2021 Sysreturn Community Contributors SPDX-License-Identifier: AGPL-3.0-or-later

Index

Constants

View Source
const (
	DefaultStoragePrefix = "uploads"
)

Variables

View Source
var (
	ErrNotFound = errors.New("NotFound")
)

Functions

func Upload

func Upload(stor Storage, f multipart.File) (string, string, error)

Types

type Storage

type Storage interface {
	Store(name string, filetype string, reader io.Reader) error
	DownloadURL(name string) (string, error)
	Delete(name string) error
	List() []string
}

type StorageFS

type StorageFS struct {
	// contains filtered or unexported fields
}

func NewStorageFS

func NewStorageFS(root ...string) *StorageFS

func (*StorageFS) Delete

func (s *StorageFS) Delete(name string) error

func (*StorageFS) DownloadURL

func (s *StorageFS) DownloadURL(name string) (string, error)

func (*StorageFS) List

func (s *StorageFS) List() []string

func (*StorageFS) Store

func (s *StorageFS) Store(name, filetype string, reader io.Reader) error

type StorageS3

type StorageS3 struct {
	S3Client      *s3.Client
	PresignClient *s3.PresignClient
	Uploader      *s3manager.Uploader
	Prefix        string
	Bucket        string
}

func NewStorageS3

func NewStorageS3(config StorageS3Config) (*StorageS3, error)

func (*StorageS3) Delete

func (s *StorageS3) Delete(name string) error

func (*StorageS3) DownloadURL

func (s *StorageS3) DownloadURL(name string) (string, error)

func (*StorageS3) List

func (s *StorageS3) List() []string

func (*StorageS3) Store

func (s *StorageS3) Store(name, filetype string, reader io.Reader) error

type StorageS3Config

type StorageS3Config struct {
	AccessKey, AccessSecret, Region, Endpoint, Bucket, Prefix string
}

Jump to

Keyboard shortcuts

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