Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPrefixNotExists = errors.New("error cstorage: prefix not found")
var ErrWithoutStorageClient = errors.New("error cstorage: select storage client")
Functions ¶
This section is empty.
Types ¶
type CreateBucketInput ¶
type CreateBucketInput struct { // Bucket name of the bucket to be created (required) Bucket string // ProjectId project id where the bucket will be created (required only google storage) ProjectId string // Location bucket, if empty using default region Location string }
CreateBucketInput input for creating a bucket
type DeleteBucketsOutput ¶
type DeleteBucketsOutput struct { // Bucket deleted bucket name Bucket string // Err an error occurred while deleting the bucket Err error }
DeleteBucketsOutput output of removing multiple buckets
type DeleteObjectInput ¶
type DeleteObjectInput struct { // Bucket name of the bucket where the object will be deleted (required) Bucket string // Key of the object to be deleted (required) Key string }
DeleteObjectInput input for removing an object from the bucket
type DeleteObjectsOutput ¶
type DeleteObjectsOutput struct { // Bucket name of the bucket where the object was deleted Bucket string // Key of the object that was deleted Key string // Err error occurred when deleting the object Err error }
DeleteObjectsOutput output of removing several objects from the bucket
type DeletePrefixInput ¶
type DeletePrefixInput struct { // Bucket name of the bucket where the objects will be deleted (required) Bucket string // Prefix name where the objects will be deleted (required) Prefix string }
DeletePrefixInput input to remove a folder (prefix) of objects from the bucket
type DeletePrefixOutput ¶
type DeletePrefixOutput struct { // Bucket name of the bucket where the objects were deleted Bucket string // Prefix that was deleted Prefix string // Err an error occurred while deleting objects from the folder Err error }
DeletePrefixOutput output of removing multiple object folders from bucket
type Interface ¶
type Interface interface { // CreateBucket creates the Bucket in the project. CreateBucket(ctx context.Context, input CreateBucketInput) error // PutObject set the value passed in the indicated bucket PutObject(ctx context.Context, input PutObjectInput) error // PutObjects set multiple values passed in the indicated bucket PutObjects(ctx context.Context, inputs ...PutObjectInput) []PutObjectOutput // GetObjectByKey returns the data for the object by name GetObjectByKey(ctx context.Context, bucket, key string) (*Object, error) // ListObjects return list objects by bucket, custom query using opts param (OptsListObjects) ListObjects(ctx context.Context, bucket string, opts ...OptsListObjects) ([]ObjectSummary, error) // DeleteObject deletes the single specified object DeleteObject(ctx context.Context, input DeleteObjectInput) error // DeleteObjects deletes multiple objects specified in the input DeleteObjects(ctx context.Context, inputs ...DeleteObjectInput) []DeleteObjectsOutput // DeleteObjectsByPrefix deletes all objects from a folder (prefix) DeleteObjectsByPrefix(ctx context.Context, input DeletePrefixInput) error // DeleteObjectsByPrefixes deletes all objects from all folders (prefix) mentioned in the input DeleteObjectsByPrefixes(ctx context.Context, input ...DeletePrefixInput) []DeletePrefixOutput // DeleteBucket deletes the Bucket DeleteBucket(ctx context.Context, bucket string) error // DeleteBuckets deletes multiple buckets mentioned in the input DeleteBuckets(ctx context.Context, buckets ...string) []DeleteBucketsOutput // Disconnect close connect to google storage Disconnect() error // SimpleDisconnect close connect to google storage, without error SimpleDisconnect() }
Interface integration with cloud storage such as Google Storage and AWS S3
func NewAwsS3Storage ¶
NewAwsS3Storage new instance of connection with AWS S3 storage, to close it just use Disconnect() or SimpleDisconnect()
func NewGoogleStorage ¶
NewGoogleStorage new instance of connection with Google storage, to close it just use Disconnect() or SimpleDisconnect()
type MimeType ¶
type MimeType string
const ( MimeTypePdf MimeType = "application/pdf" MimeTypeText MimeType = "text/plain" MimeTypeAvif MimeType = "image/avif" MimeTypeCss MimeType = "text/css; charset=utf-8" MimeTypeGif MimeType = "image/gif" MimeTypeHtml MimeType = "text/html; charset=utf-8" MimeTypeJpeg MimeType = "image/jpeg" MimeTypeJs MimeType = "text/javascript; charset=utf-8" MimeTypeJson MimeType = "application/json" MimeTypePng MimeType = "image/png" MimeTypeSvg MimeType = "image/svg+xml" MimeTypeWasm MimeType = "application/wasm" MimeTypeWebp MimeType = "image/webp" MimeTypeXml MimeType = "text/xml; charset=utf-8" )
type Object ¶
type Object struct { Key string Url string MimeType MimeType Content []byte Size int64 VersionId string LastModifiedAt time.Time }
func (Object) ParseContent ¶
type ObjectPage ¶
type ObjectPage struct { }
type ObjectSummary ¶
type OptsListObjects ¶
type OptsListObjects struct { // Delimiter returns results in a directory-like fashion. // Results will contain only objects whose names, aside from the // prefix, do not contain delimiter. Objects whose names, // aside from the prefix, contain delimiter will have their name, // truncated after the delimiter, returned in prefixes. // Duplicate prefixes are omitted. // Must be set to / when used with the MatchGlob parameter to filter results // in a directory-like mode. // Optional. Delimiter string // Prefix is the prefix filter to query objects // whose names begin with this prefix. // Optional. Prefix string }
OptsListObjects bucket object search options
func GetOptListObjectsByParams ¶
func GetOptListObjectsByParams(opts []OptsListObjects) OptsListObjects
GetOptListObjectsByParams assembles the OptsGoogleFind object from optional parameters.
func NewOptsListObjects ¶
func NewOptsListObjects() OptsListObjects
NewOptsListObjects creates a new OptsListObjects instance
func (OptsListObjects) SetDelimiter ¶
func (o OptsListObjects) SetDelimiter(s string) OptsListObjects
SetDelimiter sets value for the Delimiter field
func (OptsListObjects) SetPrefix ¶
func (o OptsListObjects) SetPrefix(s string) OptsListObjects
SetPrefix sets value for the Prefix field
type PutObjectInput ¶
type PutObjectInput struct { // Bucket name of the bucket where the object will be created (required) Bucket string // Key of the object that will be created (required) Key string // MimeType type of content of the object that will be created (required) MimeType MimeType // Content of the object that will be created (required) Content any }
PutObjectInput input for creating/updating an object in the bucket
type PutObjectOutput ¶
type PutObjectOutput struct { // Bucket name of the bucket where the object will be created Bucket string // Key of the object that will be created Key string // Err error occurred when putting the object Err error }
PutObjectOutput output for creating/updating multiple objects in the bucket