store

package
v0.0.0-...-8a6c13a Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderAutoDeleteAt      = "file-auto-delete-at"
	HeaderPrivateUrlExpires = "file-private-url-expires"
	HeaderIsPublic          = "file-is-public"
	HeaderFileName          = "file-name"
	DefaultTimeoutCtx       = 25 * time.Second
)

Since HTTP 1.1 is case insensitive, but we follow HTTP 2.0 standard which is lowercase

Variables

View Source
var AcceptedContentType = []string{
	fiber.MIMEApplicationJSONCharsetUTF8,
	fiber.MIMEApplicationJSON,
	fiber.MIMETextHTMLCharsetUTF8,
	fiber.MIMETextHTML,
	fiber.MIMETextPlainCharsetUTF8,
	fiber.MIMETextPlain,
	fiber.MIMETextJavaScriptCharsetUTF8,
	fiber.MIMETextJavaScript,
	fiber.MIMEApplicationXMLCharsetUTF8,
	fiber.MIMEApplicationXML,
	fiber.MIMETextXML,
	fiber.MIMETextXMLCharsetUTF8,
	"text/csv",
	"text/css",
	"video/mpeg",
	"audio/mpeg",
	"application/epub+zip",
	"application/epub",
	"image/gif",
	"image/jpeg",
	"application/pdf",
	"audio/wav",
	"audio/ogg",
	"image/png",
	"application/font-woff",
	"font/woff",
	"font/woff2",
	"application/x-compressed",
	"application/x-7z-compressed",

	"application/vnd.ms-excel",
	"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",

	"application/msword",
	"application/vnd.openxmlformats-officedocument.wordprocessingml.document",

	"application/vnd.ms-powerpoint",
	"application/vnd.openxmlformats-officedocument.presentationml.presentation",

	"application/x-sh",
	"image/svg+xml",
	"application/x-tar",
	"application/x-gzip",
	"application/gzip",
	"image/webp",
	"image/x-icon",
	"image/vnd.microsoft.icon",
	"image/avif",
	"application/wasm",
	"application/x-zip-compressed",
	"application/zip",
}

Functions

func DeleteObject

func DeleteObject(ctx context.Context, filePath string) error

func Format

func Format(dataFile *models.DataFile)

Format change url and fileName

func GetObject

func GetObject(ctx context.Context, filePath string) (*models.DataFile, error)

GetObject return Name object will be in format `username/filename` as standard format in upload file

func ListObjects

func ListObjects(ctx context.Context, path string, filter ...func(data *models.DataFile) bool) ([]*models.DataFile, error)

func UnmarshalMetadata

func UnmarshalMetadata(metadata map[string]string, fileData *models.DataFile) error

should guarantee metadata use lowercase as file header follow HTTP 2.0 standard

func UploadObject

func UploadObject(ctx context.Context, filePath string, fileByte []byte, fileData *models.DataFile) error

UploadObject filePath must be in format `username/filename`

Types

type FileHeader

type FileHeader map[string]string

func MapFileHeader

func MapFileHeader(header map[string][]string) FileHeader

map http header to file header return new map and key is lowercase

func (*FileHeader) Get

func (fh *FileHeader) Get(key string) string

a safe way to get value

Jump to

Keyboard shortcuts

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