or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
golangpkg:golang/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob@v1.6.4

docs

appendblob.mdblob.mdblockblob.mdclient.mdcontainer.mderrors.mdindex.mdlease.mdpageblob.mdsas.mdservice.md
tile.json

tessl/golang-github-com--azure--azure-sdk-for-go--sdk--storage--azblob

tessl install tessl/golang-github-com--azure--azure-sdk-for-go--sdk--storage--azblob@1.6.0

Azure Blob Storage SDK for Go providing comprehensive blob storage operations including uploads, downloads, container management, and advanced features like leases and SAS generation

blockblob.mddocs/

Block Blob Client (blockblob.Client)

The block blob client provides operations specific to block blobs, including uploads, staging blocks, and committing block lists.

Package Import

import "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blockblob"

Client Type

type Client struct {
    // contains filtered or unexported fields
}

Constructors

func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error)
func NewClientWithSharedKeyCredential(blobURL string, cred *blob.SharedKeyCredential, options *ClientOptions) (*Client, error)
func NewClientFromConnectionString(connectionString, containerName, blobName string, options *ClientOptions) (*Client, error)
func NewClientWithNoCredential(blobURL string, options *ClientOptions) (*Client, error)

Client Access

func (c *Client) BlobClient() *blob.Client
func (c *Client) URL() string
func (c *Client) WithSnapshot(snapshot string) (*Client, error)
func (c *Client) WithVersionID(versionID string) (*Client, error)

Upload Operations

Upload

Simple upload for smaller blobs (up to 256 MB).

func (c *Client) Upload(ctx context.Context, body io.ReadSeekCloser, options *UploadOptions) (UploadResponse, error)

Options:

type UploadOptions struct {
    HTTPHeaders        *blob.HTTPHeaders
    Metadata           map[string]*string
    Tags               map[string]string
    AccessConditions   *blob.AccessConditions
    AccessTier         *blob.AccessTier
    CPKInfo            *blob.CPKInfo
    CPKScopeInfo       *blob.CPKScopeInfo
    TransferValidation blob.TransferValidationType
}

UploadBuffer

Upload from byte buffer with automatic block management.

func (c *Client) UploadBuffer(ctx context.Context, buffer []byte, o *UploadBufferOptions) (UploadBufferResponse, error)

Options:

type UploadBufferOptions struct {
    Concurrency        uint16
    BlockSize          int64
    HTTPHeaders        *blob.HTTPHeaders
    Metadata           map[string]*string
    Tags               map[string]string
    AccessConditions   *blob.AccessConditions
    AccessTier         *blob.AccessTier
    CPKInfo            *blob.CPKInfo
    CPKScopeInfo       *blob.CPKScopeInfo
    TransferValidation blob.TransferValidationType
}

UploadFile

Upload from file with automatic block management.

func (c *Client) UploadFile(ctx context.Context, file *os.File, o *UploadFileOptions) (UploadFileResponse, error)

UploadStream

Upload from stream with automatic block management.

func (c *Client) UploadStream(ctx context.Context, body io.Reader, o *UploadStreamOptions) (UploadStreamResponse, error)

UploadBlobFromURL

Upload directly from a URL source.

func (c *Client) UploadBlobFromURL(ctx context.Context, copySource string, options *UploadBlobFromURLOptions) (UploadBlobFromURLResponse, error)

Block Operations

StageBlock

Stages a block with a specified block ID.

func (c *Client) StageBlock(ctx context.Context, base64BlockID string, body io.ReadSeekCloser, options *StageBlockOptions) (StageBlockResponse, error)

Options:

type StageBlockOptions struct {
    CPKInfo            *blob.CPKInfo
    CPKScopeInfo       *blob.CPKScopeInfo
    LeaseAccessConditions *blob.LeaseAccessConditions
    TransferValidation blob.TransferValidationType
}

Example:

import "encoding/base64"

// Create block ID
blockID := base64.StdEncoding.EncodeToString([]byte("block-001"))

// Stage block
data := bytes.NewReader([]byte("block data"))
_, err := blockBlobClient.StageBlock(ctx, blockID, streaming.NopCloser(data), nil)

StageBlockFromURL

Stages a block from a URL source.

func (c *Client) StageBlockFromURL(ctx context.Context, base64BlockID string, sourceURL string, options *StageBlockFromURLOptions) (StageBlockFromURLResponse, error)

Options:

type StageBlockFromURLOptions struct {
    SourceRange                    *blob.HTTPRange
    SourceContentMD5               []byte
    SourceContentCRC64             []byte
    CPKInfo                        *blob.CPKInfo
    CPKScopeInfo                   *blob.CPKScopeInfo
    LeaseAccessConditions          *blob.LeaseAccessConditions
    SourceModifiedAccessConditions *blob.SourceModifiedAccessConditions
}

CommitBlockList

Commits a list of staged blocks to create or update a blob.

func (c *Client) CommitBlockList(ctx context.Context, base64BlockIDs []string, options *CommitBlockListOptions) (CommitBlockListResponse, error)

Options:

type CommitBlockListOptions struct {
    HTTPHeaders        *blob.HTTPHeaders
    Metadata           map[string]*string
    Tags               map[string]string
    AccessConditions   *blob.AccessConditions
    AccessTier         *blob.AccessTier
    CPKInfo            *blob.CPKInfo
    CPKScopeInfo       *blob.CPKScopeInfo
    TransferValidation blob.TransferValidationType
}

Example:

blockIDs := []string{
    base64.StdEncoding.EncodeToString([]byte("block-001")),
    base64.StdEncoding.EncodeToString([]byte("block-002")),
    base64.StdEncoding.EncodeToString([]byte("block-003")),
}

_, err := blockBlobClient.CommitBlockList(ctx, blockIDs, nil)

GetBlockList

Retrieves the list of committed and/or uncommitted blocks.

func (c *Client) GetBlockList(ctx context.Context, listType BlockListType, options *GetBlockListOptions) (GetBlockListResponse, error)

Options:

type GetBlockListOptions struct {
    Snapshot         *string
    AccessConditions *blob.AccessConditions
}

Expiry Operations

SetExpiry

Sets blob expiry time (hierarchical namespace only).

func (c *Client) SetExpiry(ctx context.Context, expiryType ExpiryType, o *SetExpiryOptions) (SetExpiryResponse, error)

Options:

type SetExpiryOptions struct {
    ExpiresOn *time.Time
}

Constants

const (
    MaxUploadBlobBytes int64 = 256 * 1024 * 1024   // 256 MB
    MaxStageBlockBytes int64 = 4 * 1024 * 1024 * 1024 // 4 GB
    MaxBlocks          int   = 50000
    CountToEnd         int64 = 0  // Used in HTTPRange to read to end of blob
)

Enums

Block List Type

type BlockListType string

const (
    BlockListTypeCommitted   BlockListType = "committed"
    BlockListTypeUncommitted BlockListType = "uncommitted"
    BlockListTypeAll         BlockListType = "all"
)

func PossibleBlockListTypeValues() []BlockListType

Blob Copy Source Tags

type BlobCopySourceTags string

const (
    BlobCopySourceTagsCopy    BlobCopySourceTags = "COPY"
    BlobCopySourceTagsReplace BlobCopySourceTags = "REPLACE"
)

func PossibleBlobCopySourceTagsValues() []BlobCopySourceTags

Expiry Type

type ExpiryType string

const (
    ExpiryTypeAbsolute            ExpiryType = "Absolute"
    ExpiryTypeNever               ExpiryType = "NeverExpire"
    ExpiryTypeRelativeToCreation  ExpiryType = "RelativeToCreation"
    ExpiryTypeRelativeToNow       ExpiryType = "RelativeToNow"
)

func PossibleExpiryTypeValues() []ExpiryType

Types

Block

type Block struct {
    Name *string
    Size *int64
}

Block List

type BlockList struct {
    CommittedBlocks   []*Block
    UncommittedBlocks []*Block
}

Client Options

type ClientOptions struct {
    Telemetry                       policy.TelemetryOptions
    Transport                       policy.Transporter
    Retry                           policy.RetryOptions
    PerCallPolicies                 []policy.Policy
    PerRetryPolicies                []policy.Policy
    InsecureAllowCredentialWithHTTP bool
    DisableRPRegistration           bool
}