Documentation ¶
Index ¶
- type Image
- type Usecase
- func (u *Usecase) Download(ctx context.Context, imagePath string, userHash userentity.Hash, admin bool) ([]byte, error)
- func (u *Usecase) FilePathFromTemporaryPath(ctx context.Context, tempPath string) (string, error)
- func (u *Usecase) GenerateSignedURL(ctx context.Context, filePath string, expiry time.Duration) (string, error)
- func (u *Usecase) GenerateTemporaryPath(ctx context.Context, filepath string, expiryTime time.Duration) (string, error)
- func (u *Usecase) GenerateTemporaryURL(ctx context.Context, filePath string, expiry time.Duration) (string, error)
- func (u *Usecase) GetImageFilePath(ctx context.Context, imagePath string) (prefix, filePath string, err error)
- func (u *Usecase) Upload(ctx context.Context, reader io.Reader, info imageentity.FileInfo) (Image, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Image ¶
type Image struct { Proto string Host string FilePath string DownloadPath string DownloadLink string }
Image struct
type Usecase ¶
type Usecase struct {
// contains filtered or unexported fields
}
Usecase of image
func New ¶
func New(privateStorage *objectstorage.Storage, imageRepo imageRepository, objStoragePath *objstoragepath.ObjectStoragePath) (*Usecase, error)
New image usecase
func (*Usecase) Download ¶
func (u *Usecase) Download(ctx context.Context, imagePath string, userHash userentity.Hash, admin bool) ([]byte, error)
Download image download usecase never use a public storage as public storage being served via CDN and local filesystem in LOCAL to download temporary filepath, use format: temporary:{id}
func (*Usecase) FilePathFromTemporaryPath ¶
FilePathFromTemporaryPath path return the true filepath from temporary endpoint
func (*Usecase) GenerateSignedURL ¶
func (u *Usecase) GenerateSignedURL(ctx context.Context, filePath string, expiry time.Duration) (string, error)
GenerateSignedURL for generating temporary path to download image directly from object storage provider this method is different from temporary as we are not serving the download from our server
func (*Usecase) GenerateTemporaryPath ¶
func (u *Usecase) GenerateTemporaryPath(ctx context.Context, filepath string, expiryTime time.Duration) (string, error)
GenerateTemporaryPath for generating path to download image but with disposable image path this is useful for secure image handling
func (*Usecase) GenerateTemporaryURL ¶
func (u *Usecase) GenerateTemporaryURL(ctx context.Context, filePath string, expiry time.Duration) (string, error)
GenerateTemporaryURL directly from backend instad of using object-storage url, this will use image-proxy url