blockblob

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 26 Imported by: 96

Documentation

Overview

Example (Blockblob_Client)

ExampleBlockBlobClient shows how to upload data (in blocks) to a blob. A block blob can have a maximum of 50,000 blocks; each block can have a maximum of 100MB. The maximum size of a block blob is slightly more than 190 TiB (4000 MiB X 50,000 blocks).

package main

import (
	"bytes"
	"context"
	"encoding/base64"
	"encoding/binary"
	"fmt"
	"log"
	"os"
	"strings"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blockblob"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	blobName := "test_block_blob.txt"
	blobURL := fmt.Sprintf("https://%s.blob.core.windows.net/testcontainer/%s", accountName, blobName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	blockBlobClient, err := blockblob.NewClient(blobURL, cred, nil)
	handleError(err)

	// NOTE: The blockID must be <= 64 bytes and ALL blockIDs for the block must be the same length
	blockIDBinaryToBase64 := func(blockID []byte) string { return base64.StdEncoding.EncodeToString(blockID) }
	blockIDBase64ToBinary := func(blockID string) []byte { _binary, _ := base64.StdEncoding.DecodeString(blockID); return _binary }

	// These helper functions convert an int block ID to a base-64 string and vice versa
	blockIDIntToBase64 := func(blockID int) string {
		binaryBlockID := &[4]byte{} // All block IDs are 4 bytes long
		binary.LittleEndian.PutUint32(binaryBlockID[:], uint32(blockID))
		return blockIDBinaryToBase64(binaryBlockID[:])
	}
	blockIDBase64ToInt := func(blockID string) int {
		blockIDBase64ToBinary(blockID)
		return int(binary.LittleEndian.Uint32(blockIDBase64ToBinary(blockID)))
	}

	// Upload 4 blocks to the blob (these blocks are tiny; they can be up to 100MB each)
	words := []string{"Azure ", "Storage ", "Block ", "Blob."}
	base64BlockIDs := make([]string, len(words)) // The collection of block IDs (base 64 strings)

	// Upload each block sequentially (one after the other)
	for index, word := range words {
		// This example uses the index as the block ID; convert the index/ID into a base-64 encoded string as required by the service.
		// NOTE: Over the lifetime of a blob, all block IDs (before base 64 encoding) must be the same length (this example uses 4 byte block IDs).
		base64BlockIDs[index] = blockIDIntToBase64(index)

		// Upload a block to this blob specifying the Block ID and its content (up to 100MB); this block is uncommitted.
		_, err := blockBlobClient.StageBlock(context.TODO(), base64BlockIDs[index], streaming.NopCloser(strings.NewReader(word)), nil)
		if err != nil {
			log.Fatal(err)
		}
	}

	// After all the blocks are uploaded, atomically commit them to the blob.
	_, err = blockBlobClient.CommitBlockList(context.TODO(), base64BlockIDs, nil)
	handleError(err)

	// For the blob, show each block (ID and size) that is a committed part of it.
	getBlock, err := blockBlobClient.GetBlockList(context.TODO(), blockblob.BlockListTypeAll, nil)
	handleError(err)
	for _, block := range getBlock.BlockList.CommittedBlocks {
		fmt.Printf("Block ID=%d, Size=%d\n", blockIDBase64ToInt(*block.Name), block.Size)
	}

	// Download the blob in its entirety; download operations do not take blocks into account.
	blobDownloadResponse, err := blockBlobClient.DownloadStream(context.TODO(), nil)
	handleError(err)

	blobData := &bytes.Buffer{}
	reader := blobDownloadResponse.Body
	_, err = blobData.ReadFrom(reader)
	if err != nil {
		return
	}
	err = reader.Close()
	if err != nil {
		return
	}
	fmt.Println(blobData)
}
Output:

Example (Blockblob_Client_UploadFile)

This example shows how to copy a large stream in blocks (chunks) to a block blob.

package main

import (
	"context"
	"fmt"
	"log"
	"os"

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

func main() {
	file, err := os.Open("BigFile.bin") // Open the file we want to upload
	if err != nil {
		log.Fatal(err)
	}
	defer func(file *os.File) {
		err := file.Close()
		if err != nil {
		}
	}(file)
	fileSize, err := file.Stat() // Get the size of the file (stream)
	if err != nil {
		log.Panic(err)
	}

	// From the Azure portal, get your Storage account blob service URL endpoint.
	accountName, accountKey := os.Getenv("AZURE_STORAGE_ACCOUNT_NAME"), os.Getenv("AZURE_STORAGE_ACCOUNT_KEY")

	// Create a BlockBlobURL object to a blob in the container (we assume the container already exists).
	u := fmt.Sprintf("https://%s.blob.core.windows.net/mycontainer/BigBlockBlob.bin", accountName)
	credential, err := azblob.NewSharedKeyCredential(accountName, accountKey)
	if err != nil {
		log.Fatal(err) //nolint
	}
	blockBlobClient, err := blockblob.NewClientWithSharedKeyCredential(u, credential, nil)
	if err != nil {
		log.Fatal(err)
	}

	// Pass the Context, stream, stream size, block blob URL, and options to StreamToBlockBlob
	response, err := blockBlobClient.UploadFile(context.TODO(), file,
		&blockblob.UploadFileOptions{
			// If Progress is non-nil, this function is called periodically as bytes are uploaded.
			Progress: func(bytesTransferred int64) {
				fmt.Printf("Uploaded %d of %d bytes.\n", bytesTransferred, fileSize.Size())
			},
		})
	if err != nil {
		log.Fatal(err)
	}
	_ = response // Avoid compiler's "declared and not used" error

	// Set up file to download the blob to
	destFileName := "BigFile-downloaded.bin"
	destFile, err := os.Create(destFileName)
	if err != nil {
		log.Fatal(err)
	}
	defer func(destFile *os.File) {
		_ = destFile.Close()

	}(destFile)

	// Perform download
	_, err = blockBlobClient.DownloadFile(context.TODO(), destFile,
		&blob.DownloadFileOptions{
			// If Progress is non-nil, this function is called periodically as bytes are uploaded.
			Progress: func(bytesTransferred int64) {
				fmt.Printf("Downloaded %d of %d bytes.\n", bytesTransferred, fileSize.Size())
			}})

	if err != nil {
		log.Fatal(err)
	}
}
Output:

Example (Blockblob_SetExpiry)

This example shows how to set an expiry time on an existing blob This operation is only allowed on Hierarchical Namespace enabled accounts.

package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"time"

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

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	blobName := "test_block_blob_set_expiry.txt"
	blobURL := fmt.Sprintf("https://%s.blob.core.windows.net/testcontainer/%s", accountName, blobName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	blockBlobClient, err := blockblob.NewClient(blobURL, cred, nil)
	handleError(err)

	// set expiry on block blob 4 hours relative to now
	_, err = blockBlobClient.SetExpiry(context.TODO(), blockblob.ExpiryTypeRelativeToNow(4*time.Hour), nil)
	handleError(err)

	// validate set expiry operation
	resp, err := blockBlobClient.GetProperties(context.TODO(), nil)
	handleError(err)
	if resp.ExpiresOn == nil {
		return
	}
}
Output:

Example (Blockblob_uploadLogs)

This example shows how to set up log callback to dump SDK events

package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"time"

	azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blockblob"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	blobName := "test_block_blob_set_expiry.txt"
	blobURL := fmt.Sprintf("https://%s.blob.core.windows.net/testcontainer/%s", accountName, blobName)

	azlog.SetEvents(azblob.EventUpload, azlog.EventRequest, azlog.EventResponse)
	azlog.SetListener(func(cls azlog.Event, msg string) {
		if cls == azblob.EventUpload {
			fmt.Println(msg)
		}
	})

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	blockBlobClient, err := blockblob.NewClient(blobURL, cred, nil)
	handleError(err)

	// set expiry on block blob 4 hours relative to now
	_, err = blockBlobClient.SetExpiry(context.TODO(), blockblob.ExpiryTypeRelativeToNow(4*time.Hour), nil)
	handleError(err)

	// validate set expiry operation
	resp, err := blockBlobClient.GetProperties(context.TODO(), nil)
	handleError(err)
	if resp.ExpiresOn == nil {
		return
	}
}
Output:

Index

Examples

Constants

View Source
const (
	// CountToEnd specifies the end of the file.
	CountToEnd = 0

	// MaxUploadBlobBytes indicates the maximum number of bytes that can be sent in a call to Upload.
	MaxUploadBlobBytes = 256 * 1024 * 1024 // 256MB

	// MaxStageBlockBytes indicates the maximum number of bytes that can be sent in a call to StageBlock.
	MaxStageBlockBytes = 4000 * 1024 * 1024 // 4GB

	// MaxBlocks indicates the maximum number of blocks allowed in a block blob.
	MaxBlocks = 50000
)
View Source
const (
	BlobCopySourceTagsCopy    = generated.BlobCopySourceTagsCOPY
	BlobCopySourceTagsReplace = generated.BlobCopySourceTagsREPLACE
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlobCopySourceTags added in v1.2.0

type BlobCopySourceTags = generated.BlobCopySourceTags

BlobCopySourceTags - can be 'COPY' or 'REPLACE'

func PossibleBlobCopySourceTagsValues added in v1.2.0

func PossibleBlobCopySourceTagsValues() []BlobCopySourceTags

PossibleBlobCopySourceTagsValues returns the possible values for the BlobCopySourceTags const type.

type Block

type Block = generated.Block

Block - Represents a single block in a block blob. It describes the block's ID and size.

type BlockList

type BlockList = generated.BlockList

BlockList - can be uncommitted or committed blocks (committed/uncommitted)

type BlockListType

type BlockListType = generated.BlockListType

BlockListType defines values for BlockListType

const (
	BlockListTypeCommitted   BlockListType = generated.BlockListTypeCommitted
	BlockListTypeUncommitted BlockListType = generated.BlockListTypeUncommitted
	BlockListTypeAll         BlockListType = generated.BlockListTypeAll
)

func PossibleBlockListTypeValues

func PossibleBlockListTypeValues() []BlockListType

PossibleBlockListTypeValues returns the possible values for the BlockListType const type.

type Client

Client defines a set of operations applicable to block blobs.

func NewClient

func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error)

NewClient creates an instance of Client with the specified values.

  • blobURL - the URL of the blob e.g. https://<account>.blob.core.windows.net/container/blob.txt
  • cred - an Azure AD credential, typically obtained via the azidentity module
  • options - client options; pass nil to accept the default values

func NewClientFromConnectionString

func NewClientFromConnectionString(connectionString, containerName, blobName string, options *ClientOptions) (*Client, error)

NewClientFromConnectionString creates an instance of Client with the specified values.

  • connectionString - a connection string for the desired storage account
  • containerName - the name of the container within the storage account
  • blobName - the name of the blob within the container
  • options - client options; pass nil to accept the default values

func NewClientWithNoCredential

func NewClientWithNoCredential(blobURL string, options *ClientOptions) (*Client, error)

NewClientWithNoCredential creates an instance of Client with the specified values. This is used to anonymously access a blob or with a shared access signature (SAS) token.

  • blobURL - the URL of the blob e.g. https://<account>.blob.core.windows.net/container/blob.txt?<sas token>
  • options - client options; pass nil to accept the default values

func NewClientWithSharedKeyCredential

func NewClientWithSharedKeyCredential(blobURL string, cred *blob.SharedKeyCredential, options *ClientOptions) (*Client, error)

NewClientWithSharedKeyCredential creates an instance of Client with the specified values.

  • blobURL - the URL of the blob e.g. https://<account>.blob.core.windows.net/container/blob.txt
  • cred - a SharedKeyCredential created with the matching blob's storage account and access key
  • options - client options; pass nil to accept the default values

func (*Client) AbortCopyFromURL

func (bb *Client) AbortCopyFromURL(ctx context.Context, copyID string, o *blob.AbortCopyFromURLOptions) (blob.AbortCopyFromURLResponse, error)

AbortCopyFromURL stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata. For more information, see https://docs.microsoft.com/rest/api/storageservices/abort-copy-blob.

func (*Client) BlobClient

func (bb *Client) BlobClient() *blob.Client

BlobClient returns the embedded blob client for this BlockBlob client.

func (*Client) CommitBlockList

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

CommitBlockList writes a blob by specifying the list of block IDs that make up the blob. In order to be written as part of a blob, a block must have been successfully written to the server in a prior PutBlock operation. You can call PutBlockList to update a blob by uploading only those blocks that have changed, then committing the new and existing blocks together. Any blocks not specified in the block list and permanently deleted. For more information, see https://docs.microsoft.com/rest/api/storageservices/put-block-list.

func (*Client) CopyFromURL

func (bb *Client) CopyFromURL(ctx context.Context, copySource string, o *blob.CopyFromURLOptions) (blob.CopyFromURLResponse, error)

CopyFromURL synchronously copies the data at the source URL to a block blob, with sizes up to 256 MB. For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/copy-blob-from-url.

func (*Client) CreateSnapshot

CreateSnapshot creates a read-only snapshot of a blob. For more information, see https://docs.microsoft.com/rest/api/storageservices/snapshot-blob.

func (*Client) Delete

Delete marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. Note that deleting a blob also deletes all its snapshots. For more information, see https://docs.microsoft.com/rest/api/storageservices/delete-blob.

func (*Client) DeleteImmutabilityPolicy added in v0.6.0

DeleteImmutabilityPolicy operation enables users to delete the immutability policy on a blob. https://learn.microsoft.com/en-us/azure/storage/blobs/immutable-storage-overview

func (*Client) DownloadBuffer

func (bb *Client) DownloadBuffer(ctx context.Context, buffer []byte, o *blob.DownloadBufferOptions) (int64, error)

DownloadBuffer downloads an Azure blob to a buffer with parallel.

func (*Client) DownloadFile

func (bb *Client) DownloadFile(ctx context.Context, file *os.File, o *blob.DownloadFileOptions) (int64, error)

DownloadFile downloads an Azure blob to a local file. The file would be truncated if the size doesn't match.

func (*Client) DownloadStream

DownloadStream reads a range of bytes from a blob. The response also includes the blob's properties and metadata. For more information, see https://docs.microsoft.com/rest/api/storageservices/get-blob.

func (*Client) GetAccountInfo added in v1.1.0

GetAccountInfo provides account level information For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-account-information?tabs=shared-access-signatures.

func (*Client) GetBlockList

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

GetBlockList returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter. For more information, see https://docs.microsoft.com/rest/api/storageservices/get-block-list.

func (*Client) GetProperties

GetProperties returns the blob's properties. For more information, see https://docs.microsoft.com/rest/api/storageservices/get-blob-properties.

func (*Client) GetSASURL added in v1.2.1

func (bb *Client) GetSASURL(permissions sas.BlobPermissions, expiry time.Time, o *blob.GetSASURLOptions) (string, error)

GetSASURL is a convenience method for generating a SAS token for the currently pointed at block blob. It can only be used if the credential supplied during creation was a SharedKeyCredential.

func (*Client) GetTags

GetTags operation enables users to get tags on a blob or specific blob version, or snapshot. https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-tags

func (*Client) SetExpiry added in v0.6.0

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

SetExpiry operation sets an expiry time on an existing blob. This operation is only allowed on Hierarchical Namespace enabled accounts. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/set-blob-expiry

func (*Client) SetHTTPHeaders

func (bb *Client) SetHTTPHeaders(ctx context.Context, httpHeaders blob.HTTPHeaders, o *blob.SetHTTPHeadersOptions) (blob.SetHTTPHeadersResponse, error)

SetHTTPHeaders changes a blob's HTTP headers. For more information, see https://docs.microsoft.com/rest/api/storageservices/set-blob-properties.

func (*Client) SetImmutabilityPolicy added in v0.6.0

func (bb *Client) SetImmutabilityPolicy(ctx context.Context, expiryTime time.Time, options *blob.SetImmutabilityPolicyOptions) (blob.SetImmutabilityPolicyResponse, error)

SetImmutabilityPolicy operation enables users to set the immutability policy on a blob. https://learn.microsoft.com/en-us/azure/storage/blobs/immutable-storage-overview

func (*Client) SetLegalHold added in v0.6.0

func (bb *Client) SetLegalHold(ctx context.Context, legalHold bool, options *blob.SetLegalHoldOptions) (blob.SetLegalHoldResponse, error)

SetLegalHold operation enables users to set legal hold on a blob. https://learn.microsoft.com/en-us/azure/storage/blobs/immutable-storage-overview

func (*Client) SetMetadata

func (bb *Client) SetMetadata(ctx context.Context, metadata map[string]*string, o *blob.SetMetadataOptions) (blob.SetMetadataResponse, error)

SetMetadata changes a blob's metadata. https://docs.microsoft.com/rest/api/storageservices/set-blob-metadata.

func (*Client) SetTags

func (bb *Client) SetTags(ctx context.Context, tags map[string]string, o *blob.SetTagsOptions) (blob.SetTagsResponse, error)

SetTags operation enables users to set tags on a blob or specific blob version, but not snapshot. Each call to this operation replaces all existing tags attached to the blob. To remove all tags from the blob, call this operation with no tags set. https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tags

func (*Client) SetTier

SetTier operation sets the tier on a blob. The operation is allowed on a page blob in a premium storage account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's tier determines the allowed size, IOPs, and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag. For detailed information about block blob level tiering see https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers.

func (*Client) StageBlock

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

StageBlock uploads the specified block to the block blob's "staging area" to be later committed by a call to CommitBlockList. Note that the http client closes the body stream after the request is sent to the service. For more information, see https://docs.microsoft.com/rest/api/storageservices/put-block.

func (*Client) StageBlockFromURL

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

StageBlockFromURL copies the specified block from a source URL to the block blob's "staging area" to be later committed by a call to CommitBlockList. If count is CountToEnd (0), then data is read from specified offset to the end. For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/put-block-from-url.

func (*Client) StartCopyFromURL

func (bb *Client) StartCopyFromURL(ctx context.Context, copySource string, o *blob.StartCopyFromURLOptions) (blob.StartCopyFromURLResponse, error)

StartCopyFromURL copies the data at the source URL to a blob. For more information, see https://docs.microsoft.com/rest/api/storageservices/copy-blob.

func (*Client) URL

func (bb *Client) URL() string

URL returns the URL endpoint used by the Client object.

func (*Client) Undelete

Undelete restores the contents and metadata of a soft-deleted blob and any associated soft-deleted snapshots. For more information, see https://docs.microsoft.com/rest/api/storageservices/undelete-blob.

func (*Client) Upload

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

Upload creates a new block blob or overwrites an existing block blob. Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported with Upload; the content of the existing blob is overwritten with the new content. To perform a partial update of a block blob, use StageBlock and CommitBlockList. This method panics if the stream is not at position 0. Note that the http client closes the body stream after the request is sent to the service. For more information, see https://docs.microsoft.com/rest/api/storageservices/put-blob.

func (*Client) UploadBlobFromURL added in v1.1.0

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

UploadBlobFromURL - The Put Blob from URL operation creates a new Block Blob where the contents of the blob are read from a given URL. Partial updates are not supported with Put Blob from URL; the content of an existing blob is overwritten with the content of the new blob. To perform partial updates to a block blob’s contents using a source URL, use the Put Block from URL API in conjunction with Put Block List. For more information, see https://learn.microsoft.com/rest/api/storageservices/put-blob-from-url

func (*Client) UploadBuffer

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

UploadBuffer uploads a buffer in blocks to a block blob.

func (*Client) UploadFile

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

UploadFile uploads a file in blocks to a block blob.

func (*Client) UploadStream

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

UploadStream copies the file held in io.Reader to the Blob at blockBlobClient. A Context deadline or cancellation will cause this to error.

func (*Client) WithSnapshot

func (bb *Client) WithSnapshot(snapshot string) (*Client, error)

WithSnapshot creates a new Client object identical to the source but with the specified snapshot timestamp. Pass "" to remove the snapshot returning a URL to the base blob.

func (*Client) WithVersionID

func (bb *Client) WithVersionID(versionID string) (*Client, error)

WithVersionID creates a new AppendBlobURL object identical to the source but with the specified version id. Pass "" to remove the versionID returning a URL to the base blob.

type ClientOptions

type ClientOptions base.ClientOptions

ClientOptions contains the optional parameters when creating a Client.

type CommitBlockListOptions

type CommitBlockListOptions struct {
	Tags                         map[string]string
	Metadata                     map[string]*string
	RequestID                    *string
	Tier                         *blob.AccessTier
	Timeout                      *int32
	HTTPHeaders                  *blob.HTTPHeaders
	CPKInfo                      *blob.CPKInfo
	CPKScopeInfo                 *blob.CPKScopeInfo
	AccessConditions             *blob.AccessConditions
	LegalHold                    *bool
	ImmutabilityPolicyMode       *blob.ImmutabilityPolicySetting
	ImmutabilityPolicyExpiryTime *time.Time

	// Deprecated: TransactionalContentCRC64 cannot be generated
	TransactionalContentCRC64 []byte

	// Deprecated: TransactionalContentMD5 cannot be generated
	TransactionalContentMD5 []byte
}

CommitBlockListOptions contains the optional parameters for Client.CommitBlockList method.

type CommitBlockListResponse

type CommitBlockListResponse = generated.BlockBlobClientCommitBlockListResponse

CommitBlockListResponse contains the response from method Client.CommitBlockList.

type ExpiryType added in v0.6.0

type ExpiryType = exported.ExpiryType

ExpiryType defines values for ExpiryType.

type ExpiryTypeAbsolute added in v0.6.0

type ExpiryTypeAbsolute = exported.ExpiryTypeAbsolute

ExpiryTypeAbsolute defines the absolute time for the blob expiry.

type ExpiryTypeNever added in v0.6.0

type ExpiryTypeNever = exported.ExpiryTypeNever

ExpiryTypeNever defines that the blob will be set to never expire.

type ExpiryTypeRelativeToCreation added in v0.6.0

type ExpiryTypeRelativeToCreation = exported.ExpiryTypeRelativeToCreation

ExpiryTypeRelativeToCreation defines the duration relative to creation for the blob expiry.

type ExpiryTypeRelativeToNow added in v0.6.0

type ExpiryTypeRelativeToNow = exported.ExpiryTypeRelativeToNow

ExpiryTypeRelativeToNow defines the duration relative to now for the blob expiry.

type GetBlockListOptions

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

GetBlockListOptions contains the optional parameters for the Client.GetBlockList method.

type GetBlockListResponse

type GetBlockListResponse = generated.BlockBlobClientGetBlockListResponse

GetBlockListResponse contains the response from method Client.GetBlockList.

type SetExpiryOptions added in v0.6.0

type SetExpiryOptions = exported.SetExpiryOptions

SetExpiryOptions contains the optional parameters for the Client.SetExpiry method.

type SetExpiryResponse added in v0.6.0

type SetExpiryResponse = generated.BlobClientSetExpiryResponse

SetExpiryResponse contains the response from method Client.SetExpiry.

type StageBlockFromURLOptions

type StageBlockFromURLOptions struct {
	// Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source.
	CopySourceAuthorization *string

	LeaseAccessConditions *blob.LeaseAccessConditions

	SourceModifiedAccessConditions *blob.SourceModifiedAccessConditions

	// SourceContentValidation contains the validation mechanism used on the range of bytes read from the source.
	SourceContentValidation blob.SourceContentValidationType

	// Range specifies a range of bytes.  The default value is all bytes.
	Range blob.HTTPRange

	CPKInfo *blob.CPKInfo

	CPKScopeInfo *blob.CPKScopeInfo
}

StageBlockFromURLOptions contains the optional parameters for the Client.StageBlockFromURL method.

type StageBlockFromURLResponse

type StageBlockFromURLResponse = generated.BlockBlobClientStageBlockFromURLResponse

StageBlockFromURLResponse contains the response from method Client.StageBlockFromURL.

type StageBlockOptions

type StageBlockOptions struct {
	CPKInfo *blob.CPKInfo

	CPKScopeInfo *blob.CPKScopeInfo

	LeaseAccessConditions *blob.LeaseAccessConditions

	// TransactionalValidation specifies the transfer validation type to use.
	// The default is nil (no transfer validation).
	TransactionalValidation blob.TransferValidationType
}

StageBlockOptions contains the optional parameters for the Client.StageBlock method.

type StageBlockResponse

type StageBlockResponse = generated.BlockBlobClientStageBlockResponse

StageBlockResponse contains the response from method Client.StageBlock.

type UploadBlobFromURLOptions added in v1.1.0

type UploadBlobFromURLOptions struct {
	// Optional. Used to set blob tags in various blob operations.
	Tags map[string]string

	// Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source.
	CopySourceAuthorization *string

	// Optional, default is true. Indicates if properties from the source blob should be copied.
	CopySourceBlobProperties *bool

	// Optional, default 'replace'. Indicates if source tags should be copied or replaced with the tags specified by x-ms-tags.
	CopySourceTags *BlobCopySourceTags

	// Optional. Specifies a user-defined name-value pair associated with the blob.
	Metadata map[string]*string

	// Optional. Specifies the md5 calculated for the range of bytes that must be read from the copy source.
	SourceContentMD5 []byte

	// Optional. Indicates the tier to be set on the blob.
	Tier *blob.AccessTier

	// Additional optional headers
	HTTPHeaders                    *blob.HTTPHeaders
	AccessConditions               *blob.AccessConditions
	CPKInfo                        *blob.CPKInfo
	CPKScopeInfo                   *blob.CPKScopeInfo
	SourceModifiedAccessConditions *blob.SourceModifiedAccessConditions
}

UploadBlobFromURLOptions contains the optional parameters for the Client.UploadBlobFromURL method.

type UploadBlobFromURLResponse added in v1.1.0

type UploadBlobFromURLResponse = generated.BlockBlobClientPutBlobFromURLResponse

UploadBlobFromURLResponse contains the response from the method Client.UploadBlobFromURL

type UploadBufferOptions

type UploadBufferOptions = uploadFromReaderOptions

UploadBufferOptions provides set of configurations for UploadBuffer operation.

type UploadBufferResponse

type UploadBufferResponse = uploadFromReaderResponse

UploadBufferResponse contains the response from method Client.UploadBuffer/Client.UploadFile.

type UploadFileOptions

type UploadFileOptions = uploadFromReaderOptions

UploadFileOptions provides set of configurations for UploadFile operation.

type UploadFileResponse

type UploadFileResponse = uploadFromReaderResponse

UploadFileResponse contains the response from method Client.UploadBuffer/Client.UploadFile.

type UploadOptions

type UploadOptions struct {
	// Optional. Used to set blob tags in various blob operations.
	Tags map[string]string

	// Optional. Specifies a user-defined name-value pair associated with the blob.
	Metadata map[string]*string

	// Optional. Indicates the tier to be set on the blob.
	Tier *blob.AccessTier

	// TransactionalValidation specifies the transfer validation type to use.
	// The default is nil (no transfer validation).
	TransactionalValidation blob.TransferValidationType

	HTTPHeaders                  *blob.HTTPHeaders
	CPKInfo                      *blob.CPKInfo
	CPKScopeInfo                 *blob.CPKScopeInfo
	AccessConditions             *blob.AccessConditions
	LegalHold                    *bool
	ImmutabilityPolicyMode       *blob.ImmutabilityPolicySetting
	ImmutabilityPolicyExpiryTime *time.Time

	// Deprecated: TransactionalContentMD5 can be set by using TransactionalValidation instead
	TransactionalContentMD5 []byte
}

UploadOptions contains the optional parameters for the Client.Upload method.

type UploadResponse

UploadResponse contains the response from method Client.Upload.

type UploadStreamOptions

type UploadStreamOptions struct {
	// BlockSize defines the size of the buffer used during upload. The default and minimum value is 1 MiB.
	BlockSize int64

	// Concurrency defines the max number of concurrent uploads to be performed to upload the file.
	// Each concurrent upload will create a buffer of size BlockSize.  The default value is one.
	Concurrency int

	TransactionalValidation blob.TransferValidationType

	HTTPHeaders      *blob.HTTPHeaders
	Metadata         map[string]*string
	AccessConditions *blob.AccessConditions
	AccessTier       *blob.AccessTier
	Tags             map[string]string
	CPKInfo          *blob.CPKInfo
	CPKScopeInfo     *blob.CPKScopeInfo
}

UploadStreamOptions provides set of configurations for UploadStream operation.

type UploadStreamResponse

type UploadStreamResponse = CommitBlockListResponse

UploadStreamResponse contains the response from method Client.CommitBlockList.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL