Documentation
¶
Overview ¶
Package cloudstorage implements the FileStore interface using Google Cloud Storage.
Index ¶
- Constants
- Variables
- type CloudStorage
- func (s *CloudStorage) CreateSignedURL(method, path, contentType string, expiry time.Time, queries url.Values) (string, error)
- func (s *CloudStorage) CreateUploadURL(path, contentType string) (string, time.Time, error)
- func (s *CloudStorage) DeleteFile(ctx context.Context, path string) error
- func (s *CloudStorage) DeleteFolder(ctx context.Context, path string) error
- func (s *CloudStorage) GetFile(ctx context.Context, path string, version int64, expiry time.Time) (*storage.File, error)
- func (s *CloudStorage) UploadFile(ctx context.Context, path, contentType string, data []byte) error
- type Opt
Constants ¶
const ( // DefaultContentType is the default content type for files. DefaultContentType = "application/text" // ListTimeOut is the timeout for listing objects. ListTimeOut = 10 * time.Second )
const ( // DefaultUploadURLExpiry is the default expiry time for upload URLs. DefaultUploadURLExpiry = 5 * time.Minute )
Variables ¶
var ErrFileNotFound = fmt.Errorf("%w: file not found", storage.ErrNotFound)
ErrFileNotFound is returned when a file is not found.
Functions ¶
This section is empty.
Types ¶
type CloudStorage ¶
type CloudStorage struct {
// contains filtered or unexported fields
}
CloudStorage is class that handles the Google Cloud Storage operations.
func New ¶
func New(ctx context.Context, bucket *gcs.BucketHandle, accessID string, opts ...Opt) (*CloudStorage, error)
New creates a new CloudStorage instance.
func (*CloudStorage) CreateSignedURL ¶
func (s *CloudStorage) CreateSignedURL(method, path, contentType string, expiry time.Time, queries url.Values) (string, error)
CreateSignedURL creates a signed URL for a file.
func (*CloudStorage) CreateUploadURL ¶
CreateUploadURL creates a signed URL for uploading a file.
func (*CloudStorage) DeleteFile ¶
func (s *CloudStorage) DeleteFile(ctx context.Context, path string) error
DeleteFile deletes a file from gcs.
func (*CloudStorage) DeleteFolder ¶
func (s *CloudStorage) DeleteFolder(ctx context.Context, path string) error
DeleteFolder deletes a folder from gcs.
func (*CloudStorage) GetFile ¶
func (s *CloudStorage) GetFile(ctx context.Context, path string, version int64, expiry time.Time) (*storage.File, error)
GetFile retrieves a downloadable URL for a file.
func (*CloudStorage) UploadFile ¶
UploadFile uploads a file to gcs.
type Opt ¶
type Opt func(*CloudStorage)
Opt is a functional option for configuring a CloudStorage instance.
func WithLogger ¶
WithLogger sets the logger for the CloudStorage instance.
func WithUploadURLExpiry ¶
WithUploadURLExpiry sets the expiry time for signed URLs.