Documentation
¶
Index ¶
- Constants
- type AzBlob
- type AzConfig
- type AzService
- type AzUpload
- func (upload *AzUpload) DeclareLength(ctx context.Context, length int64) error
- func (upload *AzUpload) FinishUpload(ctx context.Context) error
- func (upload *AzUpload) GetInfo(ctx context.Context) (handler.FileInfo, error)
- func (upload *AzUpload) GetReader(ctx context.Context) (io.ReadCloser, error)
- func (upload *AzUpload) Terminate(ctx context.Context) error
- func (upload *AzUpload) WriteChunk(ctx context.Context, offset int64, src io.Reader) (int64, error)
- type AzureStore
- func (store AzureStore) AsLengthDeclarableUpload(upload handler.Upload) handler.LengthDeclarableUpload
- func (store AzureStore) AsTerminatableUpload(upload handler.Upload) handler.TerminatableUpload
- func (store AzureStore) GetUpload(ctx context.Context, id string) (handler.Upload, error)
- func (store AzureStore) NewUpload(ctx context.Context, info handler.FileInfo) (handler.Upload, error)
- func (store AzureStore) UseIn(composer *handler.StoreComposer)
- type BlockBlob
- func (blockBlob *BlockBlob) Commit(ctx context.Context) error
- func (blockBlob *BlockBlob) Delete(ctx context.Context) error
- func (blockBlob *BlockBlob) Download(ctx context.Context) (io.ReadCloser, error)
- func (blockBlob *BlockBlob) GetOffset(ctx context.Context) (int64, error)
- func (blockBlob *BlockBlob) StageSentinelBlock(ctx context.Context) error
- func (blockBlob *BlockBlob) Upload(ctx context.Context, body io.ReadSeeker) error
- type InfoBlob
- func (infoBlob *InfoBlob) Commit(ctx context.Context) error
- func (infoBlob *InfoBlob) Delete(ctx context.Context) error
- func (infoBlob *InfoBlob) Download(ctx context.Context) (io.ReadCloser, error)
- func (infoBlob *InfoBlob) GetOffset(ctx context.Context) (int64, error)
- func (infoBlob *InfoBlob) StageSentinelBlock(ctx context.Context) error
- func (infoBlob *InfoBlob) Upload(ctx context.Context, body io.ReadSeeker) error
Constants ¶
const ( InfoBlobSuffix string = ".info" MaxBlockBlobSize int64 = blockblob.MaxBlocks * blockblob.MaxStageBlockBytes MaxBlockBlobChunkSize int64 = blockblob.MaxStageBlockBytes )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AzBlob ¶
type AzBlob interface {
// Delete the blob
Delete(ctx context.Context) error
// Upload the blob
Upload(ctx context.Context, body io.ReadSeeker) error
// StageSentinelBlock stages a marker block so that a freshly created upload
// always has at least one uncommitted block (see GetOffset).
StageSentinelBlock(ctx context.Context) error
// Download returns a readcloser to download the contents of the blob
Download(ctx context.Context) (io.ReadCloser, error)
// Get the offset of the blob and its indexes
GetOffset(ctx context.Context) (int64, error)
// Commit the uploaded blocks to the BlockBlob
Commit(ctx context.Context) error
}
type AzService ¶
func NewAzureService ¶
New Azure service for communication to Azure BlockBlob Storage API
type AzUpload ¶
type AzUpload struct {
ID string
InfoBlob AzBlob
BlockBlob AzBlob
InfoHandler *handler.FileInfo
// contains filtered or unexported fields
}
func (*AzUpload) DeclareLength ¶
func (*AzUpload) FinishUpload ¶
Finish the file upload and commit the block list
type AzureStore ¶
type AzureStore struct {
Service AzService
ObjectPrefix string
Container string
// TemporaryDirectory is the path where AzureStore will create temporary files
// on disk during the upload. An empty string ("", the default value) will
// cause AzureStore to use the operating system's default temporary directory.
TemporaryDirectory string
}
func New ¶
func New(service AzService) *AzureStore
func (AzureStore) AsLengthDeclarableUpload ¶
func (store AzureStore) AsLengthDeclarableUpload(upload handler.Upload) handler.LengthDeclarableUpload
func (AzureStore) AsTerminatableUpload ¶
func (store AzureStore) AsTerminatableUpload(upload handler.Upload) handler.TerminatableUpload
func (AzureStore) UseIn ¶
func (store AzureStore) UseIn(composer *handler.StoreComposer)
UseIn sets this store as the core data store in the passed composer and adds all possible extension to it.
type BlockBlob ¶
type BlockBlob struct {
BlobClient *blockblob.Client
Indexes []int
BlobAccessTier *blob.AccessTier
}
func (*BlockBlob) Commit ¶
After all the blocks have been uploaded, we commit the unstaged blocks by sending a Block List
func (*BlockBlob) StageSentinelBlock ¶ added in v2.10.0
StageSentinelBlock stages a marker block so that a freshly created upload always has at least one uncommitted block. This lets GetOffset reliably tell a finished upload (no uncommitted blocks) apart from a newly created one, even when blob versioning leaves committed blocks behind on the blob (see #1349).
The marker is identified by a dedicated, reserved block ID, so it is never added to the committed block list (Commit only commits blockBlob.Indexes) and is dropped by Azure once the real blocks are committed. GetOffset skips it explicitly.
Azure rejects staging a zero-length block (it returns InvalidHeaderValue for Content-Length: 0, see #1358), so the marker carries a single byte.
type InfoBlob ¶
func (*InfoBlob) StageSentinelBlock ¶ added in v2.10.0
infoBlob does not use a sentinel block, so this is a no-op.