storages

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const ContentTypeGIF = "image/gif"
View Source
const ContentTypeJPEG = "image/jpeg"
View Source
const ContentTypeJPG = "image/jpg"
View Source
const ContentTypeJXL = "image/jxl"
View Source
const ContentTypePNG = "image/png"

image content type

Variables

This section is empty.

Functions

func AvailableImageSize

func AvailableImageSize(width int64, height int64) (isAvailable bool)

func GetImageDimensions

func GetImageDimensions(imageSize string) (width int64, height int64, isValid bool, err error)

Types

type FileData

type FileData struct {
	IsImage     bool
	Extension   string
	ImageFile   image.Image
	ContentType string
	StoragePath string
	Filename    string
}

type GCSSetup

type GCSSetup struct {
	FilePath       string
	ProjectID      string
	BucketName     string
	Region         string
	TimeOut        string
	CredentialPath string
}

type PresignUploadConfig added in v1.2.0

type PresignUploadConfig struct {
	MinSizeUpload uint64
	MaxSizeUpload uint64
	Filename      string
	FilePath      string
	ContentType   string
	ExpiredTime   *time.Time
}

type S3Setup

type S3Setup struct {
	FilePath   string
	BucketName string
	AccessKey  string
	SecretKey  string
	Region     string
}

type StorageBase

type StorageBase struct {

	// NonScaledTypes
	// if images not in this type, then file will be scaled
	// if images in this type, then file will not be scaled
	NonScaledTypes string
	// contains filtered or unexported fields
}

func NewStorageBase

func NewStorageBase(fileHeader *multipart.FileHeader, fileType string) *StorageBase

func (*StorageBase) GetFiles

func (base *StorageBase) GetFiles(storageType, storagePath, filename string) (files *os.File, err error)

func (*StorageBase) PreSignGetFiles added in v1.2.0

func (base *StorageBase) PreSignGetFiles(storageType, storagePath, filename string) (presignUrl string, err error)

func (*StorageBase) PresignUploadFiles added in v1.2.0

func (base *StorageBase) PresignUploadFiles(presignConfig PresignUploadConfig) (formData interface{}, err error)

func (*StorageBase) SetAwsS3

func (base *StorageBase) SetAwsS3(s3Setup *S3Setup) *StorageBase

func (*StorageBase) SetGoogleGCS

func (base *StorageBase) SetGoogleGCS(gcsSetup *GCSSetup) *StorageBase

func (*StorageBase) UploadFiles

func (base *StorageBase) UploadFiles() (storageModel *StorageData, err error)

type StorageData

type StorageData struct {
	Type             string `json:"type"`
	Path             string `json:"path"`
	Filename         string `json:"filename"`
	Mime             string `json:"mime"`
	OriginalFilename string `json:"original_filename"`
}

Jump to

Keyboard shortcuts

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