storage

package
v0.428.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileObjectExpiryDuration = 60 * time.Minute
	FileObjectPrefix         = "files/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	Key         string `json:"key"`
	Filename    string `json:"filename"`
	ContentType string `json:"contentType"`
	Size        int    `json:"size"`
}

FileInfo contains important data for the File type as stored in the database.

func (*FileInfo) ToDbRecord added in v0.395.9

func (fi *FileInfo) ToDbRecord() (string, error)

func (*FileInfo) ToJSON

func (fi *FileInfo) ToJSON() (string, error)

func (FileInfo) Value added in v0.404.0

func (t FileInfo) Value() (driver.Value, error)

type FileResponse added in v0.394.0

type FileResponse struct {
	Key         string `json:"key"`
	Filename    string `json:"filename"`
	ContentType string `json:"contentType"`
	Size        int    `json:"size"`
	URL         string `json:"url"`
}

FileResponse is what is returned from our APIs.

type S3BucketStore added in v0.425.0

type S3BucketStore struct {
	Client     *s3.Client
	BucketName string
	// contains filtered or unexported fields
}

func NewS3BucketStore added in v0.425.0

func NewS3BucketStore(bucketName string, client *s3.Client, tracer trace.Tracer) *S3BucketStore

func (S3BucketStore) GenerateFileResponse added in v0.425.0

func (s S3BucketStore) GenerateFileResponse(ctx context.Context, fi *FileInfo) (FileResponse, error)

func (S3BucketStore) GetFileData added in v0.425.0

func (s S3BucketStore) GetFileData(ctx context.Context, key string) ([]byte, FileInfo, error)

func (S3BucketStore) GetFileInfo added in v0.425.0

func (s S3BucketStore) GetFileInfo(ctx context.Context, key string) (FileInfo, error)

func (S3BucketStore) Store added in v0.425.0

func (s S3BucketStore) Store(ctx context.Context, dataURL string) (FileInfo, error)

type Storer

type Storer interface {
	// Store will save the given file and return a FileInfo struct for it
	//
	// The input should be a well formed dataURL https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs
	// The name of the file can also be passed as a parameter of the mediaType segment; e.g.
	// data:application/pdf;name=MyUploadedFile.pdf;base64,xxxxxx[...]
	Store(ctx context.Context, dataURL string) (FileInfo, error)

	// GetFileInfo will return the file information for the given unique file key as stored in the database.
	GetFileInfo(ctx context.Context, key string) (FileInfo, error)

	// GenerateFileResponse will take the given file info and generate a response to be returned from an API.
	//
	// The use of this function is to generate any signed URLs for file downloads.
	GenerateFileResponse(ctx context.Context, fi *FileInfo) (FileResponse, error)
}

Storer represents the interface for a file storing service that is used by the Keel runtime TODO: all these methods should take context as first arg.

Jump to

Keyboard shortcuts

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