Documentation
¶
Index ¶
- Variables
- func ReadFile(ctx context.Context, resource Resource, path string, fn ReadFileFunc) ([]byte, error)
- func UploadDir(ctx context.Context, resource Resource, src string, fn WalkDirFunc) error
- func UploadZip(ctx context.Context, resource Resource, file *os.File, fn WalkDirFunc) error
- func WalkDir(ctx context.Context, src string, walkFunc WalkDirFunc) error
- type ReadFileFunc
- type Resource
- type Storage
- type WalkDirFunc
Constants ¶
This section is empty.
Variables ¶
var ( ErrResourceNotFound = errors.New("resource not found") ErrResourceInvalidFormat = errors.New("invalid resource format") ErrEmptyResource = errors.New("resource has no content") ErrResourceAlreadyExists = errors.New("resource already exists") ErrSourceFolderNotFound = errors.New("source folder not found") ErrSourceFolderEmpty = errors.New("source folder is empty") ErrSourceFile = errors.New("source is a file, should be a folder") ErrFileNil = errors.New("no file provided") )
Functions ¶
func ReadFile ¶
ReadFile reads the content of the file located in path from the given resource. The integration the specific storage providers is provided by the ReadFileFunc.
func UploadDir ¶
UploadDir uploads the directory and all the sub elements found in src using the provided WalkDirFunc for each file found inside src. They will be uploaded as the assets for the given Resource.
Types ¶
type ReadFileFunc ¶
ReadFileFunc is used to provide integration with cloud providers while using the same business logic when reading the content of a file.
type Resource ¶
type Resource interface { // GetUUID returns the UUID v4 that identifies the current Resource. GetUUID() string // GetOwner returns who is the owner of the current Resource. GetOwner() string // GetVersion returns the numeric version of the current Resource. Resources increment their version as new // updates are introduced to them. GetVersion() uint64 }
Resource represents the resource that a user wants to download from a cloud storage.
type Storage ¶
type Storage interface { // GetFile returns the content of file from a given path. GetFile(ctx context.Context, resource Resource, path string) ([]byte, error) // Download returns a URL to download a resource from. Download(ctx context.Context, resource Resource) (string, error) // UploadDir uploads assets located in the given source folder and placed them into the given resource. UploadDir(ctx context.Context, resource Resource, source string) error // UploadZip uploads a compressed set of assets of the given resource. // // Resources can have a compressed representation of the resource itself that acts like a cache, it contains all the // files from the said resource. This function uploads that zip file. UploadZip(ctx context.Context, resource Resource, file *os.File) error }
Storage holds the methods to interact with a Cloud provider storage.
func NewGCS ¶
NewGCS initializes a new implementation of Storage using the Google Cloud Storage service.