Documentation ¶
Overview ¶
Package azblob reads/writes files to Azure blob storage in Chunks.
Package azblob reads/writes files to Azure blob storage in Chunks.
Package azblob reads/writes files to Azure blob storage in Chunks.
Package azblob reads/writes files to Azure blob storage in Chunks.
Package azblob reads/writes files to Azure blob storage in Chunks.
Package azblob reads/writes files to Azure blob storage in Chunks.
Package azblob reads/writes files to Azure blob storage in Chunks.
Index ¶
- Constants
- Variables
- type BytesSeekableReaderCloser
- type ContainerClient
- type DevConfig
- type ETagCondition
- type Error
- type GetMetadata
- type HTTPError
- type IfSinceCondition
- type LeaseRenewer
- type Option
- func WithEtagMatch(etag string) Option
- func WithEtagNoneMatch(etag string) Option
- func WithGetMetadata(value GetMetadata) Option
- func WithGetTags() Option
- func WithLeaseID(leaseID string) Option
- func WithMetadata(metadata map[string]string) Option
- func WithModifiedSince(since *time.Time) Option
- func WithSizeLimit(sizeLimit int64) Option
- func WithTags(tags map[string]string) Option
- func WithUnmodifiedSince(since *time.Time) Option
- func WithWhereTags(whereTags string) Option
- type ReaderResponse
- type ServiceClient
- type SharedKeyCredential
- type Storer
- func (azp *Storer) AcquireLease(ctx context.Context, objectname string, leaseTimeout int32) (string, error)
- func (azp *Storer) AcquireLeaseRenewable(ctx context.Context, objectname string, leaseTimeout int32) (string, LeaseRenewer, error)
- func (azp *Storer) Count(ctx context.Context, tagsFilter string) (int64, error)
- func (azp *Storer) FilteredList(ctx context.Context, tagsFilter string) ([]*azStorageBlob.FilterBlobItem, error)
- func (s *Storer) GetContainerClient() *azStorageBlob.ContainerClient
- func (s *Storer) GetServiceClient() *azStorageBlob.ServiceClient
- func (azp *Storer) Put(ctx context.Context, identity string, source io.ReadSeekCloser, opts ...Option) (*WriteResponse, error)
- func (azp *Storer) Reader(ctx context.Context, identity string, opts ...Option) (*ReaderResponse, error)
- func (azp *Storer) ReleaseLease(ctx context.Context, objectname string, leaseID string) error
- func (azp *Storer) ReleaseLeaseDeferable(ctx context.Context, objectname string, leaseID string)
- func (azp *Storer) Write(ctx context.Context, identity string, source io.Reader, opts ...Option) (*WriteResponse, error)
- func (azp *Storer) WriteStream(ctx context.Context, identity string, source *http.Request, opts ...Option) (*WriteResponse, error)
- type StorerOptions
- type WriteResponse
Constants ¶
const ( // metadata keys ContentKey = "content_type" HashKey = "hash" MimeKey = "mime_type" SizeKey = "size" TimeKey = "time_accepted" )
Variables ¶
var (
ErrMustSupportSeek0 = errors.New("must be seekable to position 0")
)
Functions ¶
This section is empty.
Types ¶
type BytesSeekableReaderCloser ¶
BytesSeekableReader closer provides reader that has a No-Op Close and a usuable Seek. Because we need Seek, we can't use ioutil.NopCloser
func NewBytesReaderCloser ¶
func NewBytesReaderCloser(b []byte) *BytesSeekableReaderCloser
func (*BytesSeekableReaderCloser) Close ¶
func (io *BytesSeekableReaderCloser) Close() error
type ContainerClient ¶
type ContainerClient = azStorageBlob.ContainerClient
so we dont have to import azure blob package anywhere else
type DevConfig ¶
func NewDevConfigFromEnv ¶
func NewDevConfigFromEnv() DevConfig
NewDevConfigFromEnv reads azurite (azure emulator) config from the standard azure env vars and falls back to the docmented defaults if they are not set. If overriding any settings via env, be sure to also configure AZURITE_ACCOUNTS for the emulator See: https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite
type ETagCondition ¶
type ETagCondition int
const ( EtagNotUsed ETagCondition = iota ETagMatch ETagNoneMatch TagsWhere )
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func ErrorFromError ¶
func NewStatusError ¶
func (*Error) IsConditionNotMet ¶
IsConditionNotMet returns true if the err is the storage code indicating that a If- header predicate (eg ETag) was not met
func (*Error) StatusCode ¶
StatusCode returns status code for failing request or 500 if code is not available on the error
func (*Error) StorageErrorCode ¶
StorageErrorCode returns the underlying azure storage ErrorCode string eg "BlobNotFound"
type GetMetadata ¶
type GetMetadata int
const ( NoMetadata GetMetadata = iota OnlyMetadata BothMetadataAndBlob )
func (GetMetadata) String ¶
func (g GetMetadata) String() string
type IfSinceCondition ¶
type IfSinceCondition int
const ( IfConditionNotUsed IfSinceCondition = iota IfConditionModifiedSince IfConditionUnmodifiedSince )
type LeaseRenewer ¶
type Option ¶
type Option func(*StorerOptions)
func WithEtagMatch ¶
WithEtagMatch succeed if the blob etag matches the provied value Typically used to make optimistic concurrency updates safe.
func WithEtagNoneMatch ¶
WithEtagNoneMatch succeed if the blob etag does *not* match the supplied value
func WithGetMetadata ¶
func WithGetMetadata(value GetMetadata) Option
WithGetMetadata specifies to get metadata - Reader() only.
func WithGetTags ¶
func WithGetTags() Option
func WithLeaseID ¶
WithLeaseID - specifies LeaseId - Reader() and Write()
func WithMetadata ¶
WithMetadata specifies metadata to add - Write() only
func WithModifiedSince ¶
func WithSizeLimit ¶
WithSizeLimit specifies the size limit of the blob. -1 for unlimited. 0+ for limited.
func WithTags ¶
WithTags specifies tags to add - Reader() and Write(). For Write) the tags are written with the blob. For Reader() the tags are used to apply ownership permissions.
func WithUnmodifiedSince ¶
func WithWhereTags ¶
WithWhereTags succeed if the where clause matches the blob tags)
type ReaderResponse ¶
type ReaderResponse struct { Reader io.ReadCloser HashValue string MimeType string Size int64 Tags map[string]string TimestampAccepted string ScannedStatus string ScannedBadReason string ScannedTimestamp string BlobClient *azStorageBlob.BlobClient // The following are copied as appropriate from the azure sdk response. // See also WriterResponse ETag *string LastModified *time.Time Metadata map[string]string // x-ms-meta header StatusCode int // For If- header fails, err can be nil and code can be 304 Status string XMsErrorCode string // will be "ConditioNotMet" for If- header predicate fails, even when err is nil }
func (*ReaderResponse) ConditionNotMet ¶
func (r *ReaderResponse) ConditionNotMet() bool
func (*ReaderResponse) DownloadToWriter ¶
func (r *ReaderResponse) DownloadToWriter(w io.Writer) error
func (*ReaderResponse) Ok ¶
func (r *ReaderResponse) Ok() bool
Ok returns true if the http status was 200 or 201 This method is provided for use in combination with specific headers like If-Match and ETags conditions. In thos circumstances we often get err=nil but no content.
type ServiceClient ¶
type ServiceClient = azStorageBlob.ServiceClient
type SharedKeyCredential ¶
type SharedKeyCredential = azStorageBlob.SharedKeyCredential
type Storer ¶
type Storer struct { AccountName string ResourceGroup string Subscription string Container string // contains filtered or unexported fields }
Storer implements usage of Reader/Writer backed by azblob
func New ¶
func New( accountName string, resourceGroup string, subscription string, container string, ) (*Storer, error)
New returns new az blob read/write object
func NewDev ¶
NewDev returns a normal blob client but connected for the azurite local emulator It uses the well known account name and key by default. If overriding, be sure to also configure AZURITE_ACCOUNTS for the emulator See: https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite
func (*Storer) AcquireLease ¶
func (azp *Storer) AcquireLease( ctx context.Context, objectname string, leaseTimeout int32, ) (string, error)
AcquireLease gets a lease on a blob
func (*Storer) AcquireLeaseRenewable ¶
func (*Storer) FilteredList ¶
func (azp *Storer) FilteredList(ctx context.Context, tagsFilter string) ([]*azStorageBlob.FilterBlobItem, error)
FilteredList returns a list of blobs filtered on their tag values.
tagsFilter example: "dog='germanshepherd' and penguin='emperorpenguin'" Returns all blobs with the specific tag filter
func (*Storer) GetContainerClient ¶
func (s *Storer) GetContainerClient() *azStorageBlob.ContainerClient
GetContainerClient returns the underlying container client
func (*Storer) GetServiceClient ¶
func (s *Storer) GetServiceClient() *azStorageBlob.ServiceClient
GetServiceClient returns the underlying service client
func (*Storer) Put ¶
func (azp *Storer) Put( ctx context.Context, identity string, source io.ReadSeekCloser, opts ...Option, ) (*WriteResponse, error)
Put creates or replaces a blob metadata and tags are set in the same operation as the content update.
func (*Storer) Reader ¶
func (azp *Storer) Reader( ctx context.Context, identity string, opts ...Option, ) (*ReaderResponse, error)
Reader creates a reader.
func (*Storer) ReleaseLease ¶
ReleaseLease release a lease on a blob
func (*Storer) ReleaseLeaseDeferable ¶
ReleaseLeaseDeferable this is intended to use with defer - doesn't return error so we don't need to check it
type StorerOptions ¶
type StorerOptions struct {
// contains filtered or unexported fields
}
StorerOptions - optional args for specifying optional behaviour
type WriteResponse ¶
type WriteResponse struct { HashValue string MimeType string Size int64 TimestampAccepted string // The following fields are copied from the sdk response. nil pointers mean // 'not set'. Note that different azure blob sdk write mode apis (put, // create, stream) etc return different generated types. So we copy only the // fields which make sense into this unified type. And we only copy values // which can be made use of in the api presented by this package. ETag *string LastModified *time.Time StatusCode int // For If- header fails, err can be nil and code can be 304 Status string XMsErrorCode string // will be "ConditioNotMet" for If- header predicate fails, even when err is nil }