Documentation ¶
Overview ¶
Package gcstorage is an implementation of filestorage for Google Cloud
Index ¶
- type Creator
- type GCStorage
- func (s *GCStorage) Attributes(filepath string) (*filestorage.FileAttributes, error)
- func (s *GCStorage) AttributesCtx(ctx context.Context, filepath string) (*filestorage.FileAttributes, error)
- func (s *GCStorage) Delete(filepath string) error
- func (s *GCStorage) DeleteCtx(ctx context.Context, filepath string) error
- func (s *GCStorage) Exists(filepath string) (bool, error)
- func (s *GCStorage) ExistsCtx(ctx context.Context, filepath string) (bool, error)
- func (s *GCStorage) ID() string
- func (s *GCStorage) Read(filepath string) (io.ReadCloser, error)
- func (s *GCStorage) ReadCtx(ctx context.Context, filepath string) (io.ReadCloser, error)
- func (s *GCStorage) SetAttributes(filepath string, attrs *filestorage.UpdatableFileAttributes) (*filestorage.FileAttributes, error)
- func (s *GCStorage) SetAttributesCtx(ctx context.Context, filepath string, ...) (*filestorage.FileAttributes, error)
- func (s *GCStorage) SetBucket(name string) error
- func (s *GCStorage) URL(filepath string) (string, error)
- func (s *GCStorage) URLCtx(ctx context.Context, filepath string) (string, error)
- func (s *GCStorage) Write(src io.Reader, destPath string) error
- func (s *GCStorage) WriteCtx(ctx context.Context, src io.Reader, destPath string) error
- func (s *GCStorage) WriteIfNotExist(src io.Reader, destPath string) (new bool, url string, err error)
- func (s *GCStorage) WriteIfNotExistCtx(ctx context.Context, src io.Reader, destPath string) (new bool, url string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Creator ¶
type Creator struct {
// contains filtered or unexported fields
}
Creator creates new filestorage
func NewCreator ¶
NewCreator returns a filestorage creator that will use the provided key to create a new google storage client that will be reused for every new gcstorage instance
func NewCreatorWithContext ¶
func NewCreatorWithContext(ctx context.Context, apiKey string, defaultBucket string) (*Creator, error)
NewCreatorWithContext returns a filestorage creator that will use the provided context and key to create a new google storage client that will be reused for every new gcstorage instance The provided context will be used as default context for all new FileStorage instance
type GCStorage ¶
type GCStorage struct {
// contains filtered or unexported fields
}
GCStorage is an implementation of the FileStorage interface for Google Cloud
func NewWithClient ¶
NewWithClient returns a new instance of a Google Cloud Storage using the provided client
func NewWithContext ¶
NewWithContext returns a new GCStorage instance using a new Google Cloud Storage client attached to the provided context
func (*GCStorage) Attributes ¶
Attributes returns the attributes of the file Will use the defaut context
func (*GCStorage) AttributesCtx ¶
func (s *GCStorage) AttributesCtx(ctx context.Context, filepath string) (*filestorage.FileAttributes, error)
AttributesCtx returns the attributes of the file
func (*GCStorage) Delete ¶
Delete removes a file, ignores files that do not exist Will use the defaut context
func (*GCStorage) Read ¶
func (s *GCStorage) Read(filepath string) (io.ReadCloser, error)
Read fetches a file a returns a reader Will use the defaut context
func (*GCStorage) SetAttributes ¶
func (s *GCStorage) SetAttributes(filepath string, attrs *filestorage.UpdatableFileAttributes) (*filestorage.FileAttributes, error)
SetAttributes sets the attributes of the file Will use the defaut context
func (*GCStorage) SetAttributesCtx ¶
func (s *GCStorage) SetAttributesCtx(ctx context.Context, filepath string, attrs *filestorage.UpdatableFileAttributes) (*filestorage.FileAttributes, error)
SetAttributesCtx sets the attributes of the file
func (*GCStorage) WriteIfNotExist ¶
func (s *GCStorage) WriteIfNotExist(src io.Reader, destPath string) (new bool, url string, err error)
WriteIfNotExist copies the provided io.Reader to dest if the file does not already exist Returns:
- A boolean specifying if the file got uploaded (true) or if already existed (false).
- A URL to the uploaded file
- An error if something went wrong
Will use the defaut context
func (*GCStorage) WriteIfNotExistCtx ¶
func (s *GCStorage) WriteIfNotExistCtx(ctx context.Context, src io.Reader, destPath string) (new bool, url string, err error)
WriteIfNotExistCtx copies the provided io.Reader to dest if the file does not already exist Returns:
- A boolean specifying if the file got uploaded (true) or if already existed (false).
- A URL to the uploaded file
- An error if something went wrong