Documentation
¶
Overview ¶
Package url abstracts local and remote file StorageURLs.
Index ¶
- type Metadata
- type Object
- type ObjectType
- type Option
- type Storage
- func (s *Storage) DownloadFile(ctx context.Context, bucketName string, objectKey string, localFile string) error
- func (s *Storage) UploadFile(ctx context.Context, fileName string, bucketName string, objectKey string) (*s3.PutObjectOutput, error)
- func (s *Storage) UploadFromStdin(ctx context.Context, bucketName string, objectKey string) (*manager.UploadOutput, error)
- type StorageClass
- type StorageOption
- type StorageURL
- func (u *StorageURL) Absolute() string
- func (u *StorageURL) Base() string
- func (u *StorageURL) Clone() *StorageURL
- func (u *StorageURL) Dir() string
- func (u *StorageURL) EscapedPath() string
- func (u *StorageURL) IsBucket() bool
- func (u *StorageURL) IsPrefix() bool
- func (u *StorageURL) IsRaw() bool
- func (u *StorageURL) IsRemote() bool
- func (u *StorageURL) IsVersioned() bool
- func (u *StorageURL) IsWildcard() bool
- func (u *StorageURL) Join(s string) *StorageURL
- func (u StorageURL) MarshalJSON() ([]byte, error)
- func (u *StorageURL) Match(key string) bool
- func (u *StorageURL) Relative() string
- func (u *StorageURL) SetRelative(base *StorageURL)
- func (u *StorageURL) String() string
- func (u StorageURL) ToBytes() []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metadata ¶
type Metadata struct {
ACL string
CacheControl string
Expires string
StorageClass string
ContentType string
ContentEncoding string
ContentDisposition string
EncryptionMethod string
EncryptionKeyID string
UserDefined map[string]string
// MetadataDirective is used to specify whether the metadata is copied from
// the source object or replaced with metadata provided when copying S3
// objects. If MetadataDirective is not set, it defaults to "COPY".
Directive string
}
type Object ¶
type Object struct {
StorageURL *StorageURL `json:"key,omitempty"`
Etag string `json:"etag,omitempty"`
ModTime *time.Time `json:"last_modified,omitempty"`
Type ObjectType `json:"type,omitempty"`
Size int64 `json:"size,omitempty"`
StorageClass StorageClass `json:"storage_class,omitempty"`
Err error `json:"error,omitempty"`
// the VersionID field exist only for JSON Marshall, it must not be used for
// any other purpose. URL.VersionID must be used instead.
VersionID string `json:"version_id,omitempty"`
// contains filtered or unexported fields
}
Object is a generic type which contains metadata for storage items.
type ObjectType ¶
type ObjectType struct {
// contains filtered or unexported fields
}
ObjectType is the type of Object.
func (ObjectType) IsDir ¶
func (o ObjectType) IsDir() bool
IsDir checks if the object is a directory.
func (ObjectType) IsRegular ¶
func (o ObjectType) IsRegular() bool
IsRegular checks if the object is a regular file.
func (ObjectType) IsSymlink ¶
func (o ObjectType) IsSymlink() bool
IsSymlink checks if the object is a symbolic link.
func (ObjectType) MarshalJSON ¶
func (o ObjectType) MarshalJSON() ([]byte, error)
MarshalJSON returns the stringer of ObjectType as a marshalled json.
func (ObjectType) String ¶
func (o ObjectType) String() string
String returns the string representation of ObjectType.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func NewStorage ¶
func NewStorage(ctx context.Context, option StorageOption) (*Storage, error)
func (*Storage) DownloadFile ¶
func (*Storage) UploadFile ¶
func (*Storage) UploadFromStdin ¶ added in v0.0.2
type StorageClass ¶
type StorageClass string
StorageClass represents the storage used to store an object.
type StorageOption ¶ added in v0.0.3
type StorageOption struct {
// contains filtered or unexported fields
}
func NewStorageOption ¶ added in v0.0.3
func NewStorageOption(s3opt s3store.S3Option, localopt fsstore.LocalOption) *StorageOption
type StorageURL ¶
type StorageURL struct {
Type urlType
Scheme string
Bucket string
Path string
Delimiter string
Prefix string
VersionID string
AllVersions bool
// contains filtered or unexported fields
}
StorageURL is the canonical representation of an object, either on local or remote storage.
func NewStorageURL ¶
func NewStorageURL(s string, opts ...Option) (*StorageURL, error)
New creates a new StorageURL from given path string.
func (*StorageURL) Absolute ¶
func (u *StorageURL) Absolute() string
Absolute returns the absolute StorageURL format of the object.
func (*StorageURL) Base ¶
func (u *StorageURL) Base() string
Base returns the last element of object path.
func (*StorageURL) Clone ¶
func (u *StorageURL) Clone() *StorageURL
Clone creates a copy of the receiver.
func (*StorageURL) Dir ¶
func (u *StorageURL) Dir() string
Dir returns all but the last element of path, typically the path's directory.
func (*StorageURL) EscapedPath ¶
func (u *StorageURL) EscapedPath() string
func (*StorageURL) IsBucket ¶
func (u *StorageURL) IsBucket() bool
IsBucket returns true if the object url contains only bucket name
func (*StorageURL) IsPrefix ¶
func (u *StorageURL) IsPrefix() bool
IsPrefix reports whether the remote object is an S3 prefix, and does not look like an object.
func (*StorageURL) IsRaw ¶
func (u *StorageURL) IsRaw() bool
func (*StorageURL) IsRemote ¶
func (u *StorageURL) IsRemote() bool
IsRemote reports whether the object is stored on a remote storage system.
func (*StorageURL) IsVersioned ¶
func (u *StorageURL) IsVersioned() bool
IsVersioned returns true if the StorageURL has versioning related values
func (*StorageURL) IsWildcard ¶
func (u *StorageURL) IsWildcard() bool
IsWildcard reports whether if a string contains any wildcard chars.
func (*StorageURL) Join ¶
func (u *StorageURL) Join(s string) *StorageURL
Join joins string and returns new StorageURL.
func (StorageURL) MarshalJSON ¶
func (u StorageURL) MarshalJSON() ([]byte, error)
MarshalJSON is the json.Marshaler implementation of StorageURL.
func (*StorageURL) Match ¶
func (u *StorageURL) Match(key string) bool
Match reports whether if given key matches with the object.
func (*StorageURL) Relative ¶
func (u *StorageURL) Relative() string
Relative returns a URI reference based on the calculated prefix.
func (*StorageURL) SetRelative ¶
func (u *StorageURL) SetRelative(base *StorageURL)
SetRelative explicitly sets the relative path of u against given base value. If the base path contains `globCharacters` then, the relative path is determined with respect to the parent directory of the so called wildcarded object.
func (*StorageURL) String ¶
func (u *StorageURL) String() string
String is the fmt.Stringer implementation of StorageURL.
func (StorageURL) ToBytes ¶
func (u StorageURL) ToBytes() []byte