Movatterモバイル変換


[0]ホーム

URL:


blob

package
v1.6.3Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License:MITImports:18Imported by:205

Details

Repository

github.com/Azure/azure-sdk-for-go

Links

Documentation

Overview

Example (Blob_Client_CreateSnapshot)

This example show how to create a blob, take a snapshot of it, update the base blob,read from the blob snapshot, list blobs with their snapshots, and delete blob snapshots.

package mainimport ("bytes""context""fmt""log""os""strings""github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming""github.com/Azure/azure-sdk-for-go/sdk/azcore/to""github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob""github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container")func handleError(err error) {if err != nil {log.Fatal(err.Error())}}func main() {accountName, accountKey := os.Getenv("AZURE_STORAGE_ACCOUNT_NAME"), os.Getenv("AZURE_STORAGE_ACCOUNT_KEY")u := fmt.Sprintf("https://%s.blob.core.windows.net/mycontainer", accountName)credential, err := blob.NewSharedKeyCredential(accountName, accountKey)handleError(err)containerClient, err := container.NewClientWithSharedKeyCredential(u, credential, nil)handleError(err)// Create a blockBlobClient object to a blob in the container.baseBlobClient := containerClient.NewBlockBlobClient("Original.txt")// Create the original blob:_, err = baseBlobClient.Upload(context.TODO(), streaming.NopCloser(streaming.NopCloser(strings.NewReader("Some text"))), nil)handleError(err)// Create a snapshot of the original blob & save its timestamp:createSnapshot, err := baseBlobClient.CreateSnapshot(context.TODO(), nil)handleError(err)snapshot := *createSnapshot.Snapshot// Modify the original blob:_, err = baseBlobClient.Upload(context.TODO(), streaming.NopCloser(strings.NewReader("New text")), nil)handleError(err)// Download the modified blob:get, err := baseBlobClient.DownloadStream(context.TODO(), nil)handleError(err)b := bytes.Buffer{}reader := get.Body_, err = b.ReadFrom(reader)if err != nil {return}err = reader.Close()if err != nil {return}fmt.Println(b.String())// Show snapshot blob via original blob URI & snapshot time:snapshotBlobClient, _ := baseBlobClient.WithSnapshot(snapshot)get, err = snapshotBlobClient.DownloadStream(context.TODO(), nil)handleError(err)b.Reset()reader = get.Body_, err = b.ReadFrom(reader)if err != nil {return}err = reader.Close()if err != nil {return}fmt.Println(b.String())// FYI: You can get the base blob URL from one of its snapshot by passing "" to WithSnapshot:baseBlobClient, _ = snapshotBlobClient.WithSnapshot("")// Show all blobs in the container with their snapshots:// List the blob(s) in our container; since a container may hold millions of blobs, this is done 1 segment at a time.pager := containerClient.NewListBlobsFlatPager(nil)for pager.More() {resp, err := pager.NextPage(context.TODO())if err != nil {log.Fatal(err)}for _, blob := range resp.Segment.BlobItems {// Process the blobs returnedsnapTime := "N/A"if blob.Snapshot != nil {snapTime = *blob.Snapshot}fmt.Printf("Blob name: %s, Snapshot: %s\n", *blob.Name, snapTime)}}// Promote read-only snapshot to writable base blob:_, err = baseBlobClient.StartCopyFromURL(context.TODO(), snapshotBlobClient.URL(), nil)handleError(err)// When calling Delete on a base blob:// DeleteSnapshotsOptionOnly deletes all the base blob's snapshots but not the base blob itself// DeleteSnapshotsOptionInclude deletes the base blob & all its snapshots.// DeleteSnapshotOptionNone produces an error if the base blob has any snapshots._, err = baseBlobClient.Delete(context.TODO(), &blob.DeleteOptions{DeleteSnapshots: to.Ptr(blob.DeleteSnapshotsOptionTypeInclude)})handleError(err)}

Example (Blob_Client_SetMetadata)

This example shows how to create a blob with metadata, read blob metadata, and update a blob's read-only properties and metadata.

package mainimport ("context""fmt""log""os""strings""github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming""github.com/Azure/azure-sdk-for-go/sdk/azcore/to""github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob""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, accountKey := os.Getenv("AZURE_STORAGE_ACCOUNT_NAME"), os.Getenv("AZURE_STORAGE_ACCOUNT_KEY")// Create a blob clientu := fmt.Sprintf("https://%s.blob.core.windows.net/mycontainer/ReadMe.txt", accountName)credential, err := blob.NewSharedKeyCredential(accountName, accountKey)handleError(err)blobClient, err := blockblob.NewClientWithSharedKeyCredential(u, credential, nil)handleError(err)// Create a blob with metadata (string key/value pairs)// Metadata key names are always converted to lowercase before being sent to the Storage Service.// Always use lowercase letters; especially when querying a map for a metadata key.creatingApp, err := os.Executable()handleError(err)_, err = blobClient.Upload(context.TODO(),streaming.NopCloser(strings.NewReader("Some text")),&blockblob.UploadOptions{Metadata: map[string]*string{"author": to.Ptr("Jeffrey"), "app": to.Ptr(creatingApp)}},)handleError(err)// Query the blob's properties and metadataget, err := blobClient.GetProperties(context.TODO(), nil)handleError(err)// Show some of the blob's read-only propertiesfmt.Printf("BlobType: %s\nETag: %s\nLastModified: %s\n", *get.BlobType, *get.ETag, *get.LastModified)// Show the blob's metadataif get.Metadata == nil {log.Fatal("No metadata returned")}for k, v := range get.Metadata {fmt.Print(k + "=" + *v + "\n")}// Update the blob's metadata and write it back to the blobget.Metadata["editor"] = to.Ptr("Grant")_, err = blobClient.SetMetadata(context.TODO(), get.Metadata, nil)handleError(err)}

Example (Blob_Client_StartCopyFromURL)

This example shows how to copy a source document on the Internet to a blob.

package mainimport ("context""fmt""log""os""time""github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob")func handleError(err error) {if err != nil {log.Fatal(err.Error())}}func main() {accountName, accountKey := os.Getenv("AZURE_STORAGE_ACCOUNT_NAME"), os.Getenv("AZURE_STORAGE_ACCOUNT_KEY")// Create a containerClient object to a container where we'll create a blob and its snapshot.// Create a blockBlobClient object to a blob in the container.blobURL := fmt.Sprintf("https://%s.blob.core.windows.net/mycontainer/CopiedBlob.bin", accountName)credential, err := blob.NewSharedKeyCredential(accountName, accountKey)handleError(err)blobClient, err := blob.NewClientWithSharedKeyCredential(blobURL, credential, nil)handleError(err)src := "https://cdn2.auth0.com/docs/media/addons/azure_blob.svg"startCopy, err := blobClient.StartCopyFromURL(context.TODO(), src, nil)handleError(err)copyID := *startCopy.CopyIDcopyStatus := *startCopy.CopyStatusfor copyStatus == blob.CopyStatusTypePending {time.Sleep(time.Second * 2)getMetadata, err := blobClient.GetProperties(context.TODO(), nil)if err != nil {log.Fatal(err)}copyStatus = *getMetadata.CopyStatus}fmt.Printf("Copy from %s to %s: ID=%s, Status=%s\n", src, blobClient.URL(), copyID, copyStatus)}

Example (Blob_HTTPHeaders)

This examples shows how to create a blob with HTTP Headers, how to read, and how to update the blob's HTTP headers.

package mainimport ("context""fmt""log""os""strings""github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming""github.com/Azure/azure-sdk-for-go/sdk/azcore/to""github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob""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, accountKey := os.Getenv("AZURE_STORAGE_ACCOUNT_NAME"), os.Getenv("AZURE_STORAGE_ACCOUNT_KEY")// Create a blob clientu := fmt.Sprintf("https://%s.blob.core.windows.net/mycontainer/ReadMe.txt", accountName)credential, err := blob.NewSharedKeyCredential(accountName, accountKey)handleError(err)blobClient, err := blockblob.NewClientWithSharedKeyCredential(u, credential, nil)handleError(err)// Create a blob with HTTP headers_, err = blobClient.Upload(context.TODO(),streaming.NopCloser(strings.NewReader("Some text")),&blockblob.UploadOptions{HTTPHeaders: &blob.HTTPHeaders{BlobContentType:        to.Ptr("text/html; charset=utf-8"),BlobContentDisposition: to.Ptr("attachment"),}},)handleError(err)// GetMetadata returns the blob's properties, HTTP headers, and metadataget, err := blobClient.GetProperties(context.TODO(), nil)handleError(err)// Show some of the blob's read-only propertiesfmt.Printf("BlobType: %s\nETag: %s\nLastModified: %s\n", *get.BlobType, *get.ETag, *get.LastModified)// Shows some of the blob's HTTP HeadershttpHeaders := blob.ParseHTTPHeaders(get)fmt.Println(httpHeaders.BlobContentType, httpHeaders.BlobContentDisposition)// Update the blob's HTTP Headers and write them back to the blobhttpHeaders.BlobContentType = to.Ptr("text/plain")_, err = blobClient.SetHTTPHeaders(context.TODO(), httpHeaders, nil)handleError(err)}

Index

Examples

Constants

View Source
const (CountToEnd = 0SnapshotTimeFormat =exported.SnapshotTimeFormat// DefaultDownloadBlockSize is default block sizeDefaultDownloadBlockSize =int64(4 * 1024 * 1024)// 4MB// DefaultConcurrency is the default number of blocks downloaded or uploaded in parallelDefaultConcurrency =shared.DefaultConcurrency)
View Source
const ReadOnClosedBodyMessage = "read on closed response body"

ReadOnClosedBodyMessage of retry reader

Variables

This section is empty.

Functions

This section is empty.

Types

typeAbortCopyFromURLOptions

type AbortCopyFromURLOptions struct {LeaseAccessConditions *LeaseAccessConditions}

AbortCopyFromURLOptions contains the optional parameters for the Client.AbortCopyFromURL method.

typeAbortCopyFromURLResponse

type AbortCopyFromURLResponse =generated.BlobClientAbortCopyFromURLResponse

AbortCopyFromURLResponse contains the response from method BlobClient.AbortCopyFromURL.

typeAccessConditions

type AccessConditions =exported.BlobAccessConditions

AccessConditions identifies blob-specific access conditions which you optionally set.

typeAccessTier

type AccessTier =generated.AccessTier

AccessTier defines values for Blob Access Tier.

funcPossibleAccessTierValues

func PossibleAccessTierValues() []AccessTier

PossibleAccessTierValues returns the possible values for the AccessTier const type.

typeAcquireLeaseResponse

type AcquireLeaseResponse =generated.BlobClientAcquireLeaseResponse

AcquireLeaseResponse contains the response from method BlobClient.AcquireLease.

typeArchiveStatus

type ArchiveStatus =generated.ArchiveStatus

ArchiveStatus defines values for ArchiveStatus.

const (ArchiveStatusRehydratePendingToCoolArchiveStatus =generated.ArchiveStatusRehydratePendingToCoolArchiveStatusRehydratePendingToHotArchiveStatus =generated.ArchiveStatusRehydratePendingToHotArchiveStatusRehydratePendingToColdArchiveStatus =generated.ArchiveStatusRehydratePendingToCold)

funcPossibleArchiveStatusValues

func PossibleArchiveStatusValues() []ArchiveStatus

PossibleArchiveStatusValues returns the possible values for the ArchiveStatus const type.

typeBlobType

type BlobType =generated.BlobType

BlobType defines values for BlobType

const (BlobTypeBlockBlobBlobType =generated.BlobTypeBlockBlobBlobTypePageBlobBlobType =generated.BlobTypePageBlobBlobTypeAppendBlobBlobType =generated.BlobTypeAppendBlob)

funcPossibleBlobTypeValues

func PossibleBlobTypeValues() []BlobType

PossibleBlobTypeValues returns the possible values for the BlobType const type.

typeBreakLeaseResponse

type BreakLeaseResponse =generated.BlobClientBreakLeaseResponse

BreakLeaseResponse contains the response from method BlobClient.BreakLease.

typeCPKInfoadded inv1.0.0

type CPKInfo =generated.CPKInfo

CPKInfo contains a group of parameters for client provided encryption key.

typeCPKScopeInfoadded inv1.0.0

type CPKScopeInfo =generated.CPKScopeInfo

CPKScopeInfo contains a group of parameters for client provided encryption scope.

typeChangeLeaseResponse

type ChangeLeaseResponse =generated.BlobClientChangeLeaseResponse

ChangeLeaseResponse contains the response from method BlobClient.ChangeLease.

typeClient

Client represents a URL to an Azure Storage blob; the blob may be a block blob, append blob, or page blob.

funcNewClient

func NewClient(blobURLstring, credazcore.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

funcNewClientFromConnectionString

func NewClientFromConnectionString(connectionString, containerName, blobNamestring, 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

funcNewClientWithNoCredential

func NewClientWithNoCredential(blobURLstring, 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

funcNewClientWithSharedKeyCredential

func NewClientWithSharedKeyCredential(blobURLstring, cred *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 (b *Client) AbortCopyFromURL(ctxcontext.Context, copyIDstring, options *AbortCopyFromURLOptions) (AbortCopyFromURLResponse,error)

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

func (*Client)CopyFromURL

func (b *Client) CopyFromURL(ctxcontext.Context, copySourcestring, options *CopyFromURLOptions) (CopyFromURLResponse,error)

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

func (*Client)CreateSnapshot

func (b *Client) CreateSnapshot(ctxcontext.Context, options *CreateSnapshotOptions) (CreateSnapshotResponse,error)

CreateSnapshot creates a read-only snapshot of a blob.For more information, seehttps://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, seehttps://docs.microsoft.com/rest/api/storageservices/delete-blob.

func (*Client)DeleteImmutabilityPolicyadded inv0.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 (b *Client) DownloadBuffer(ctxcontext.Context, buffer []byte, o *DownloadBufferOptions) (int64,error)

DownloadBuffer downloads an Azure blob to a buffer with parallel.

func (*Client)DownloadFile

func (b *Client) DownloadFile(ctxcontext.Context, file *os.File, o *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, seehttps://docs.microsoft.com/rest/api/storageservices/get-blob.

func (*Client)GetAccountInfoadded inv1.1.0

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

func (*Client)GetProperties

func (b *Client) GetProperties(ctxcontext.Context, options *GetPropertiesOptions) (GetPropertiesResponse,error)

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

func (*Client)GetSASURL

func (b *Client) GetSASURL(permissionssas.BlobPermissions, expirytime.Time, o *GetSASURLOptions) (string,error)

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

func (*Client)GetTags

func (b *Client) GetTags(ctxcontext.Context, options *GetTagsOptions) (GetTagsResponse,error)

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)SetHTTPHeaders

func (b *Client) SetHTTPHeaders(ctxcontext.Context, httpHeadersHTTPHeaders, o *SetHTTPHeadersOptions) (SetHTTPHeadersResponse,error)

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

func (*Client)SetImmutabilityPolicyadded inv0.6.0

func (b *Client) SetImmutabilityPolicy(ctxcontext.Context, expiryTimetime.Time, options *SetImmutabilityPolicyOptions) (SetImmutabilityPolicyResponse,error)

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

func (*Client)SetLegalHoldadded inv0.6.0

func (b *Client) SetLegalHold(ctxcontext.Context, legalHoldbool, options *SetLegalHoldOptions) (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 (b *Client) SetMetadata(ctxcontext.Context, metadata map[string]*string, o *SetMetadataOptions) (SetMetadataResponse,error)

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

func (*Client)SetTags

func (b *Client) SetTags(ctxcontext.Context, tags map[string]string, options *SetTagsOptions) (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 pageblob in a premium storage account and on a block blob in a blob storage account (locallyredundant storage only). A premium page blob's tier determines the allowed size, IOPs, andbandwidth of the blob. A block blob's tier determines Hot/Cool/Archive storage type. This operationdoes not update the blob's ETag.For detailed information about block blob level tiers seehttps://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers.

func (*Client)StartCopyFromURL

func (b *Client) StartCopyFromURL(ctxcontext.Context, copySourcestring, options *StartCopyFromURLOptions) (StartCopyFromURLResponse,error)

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

func (*Client)URL

func (b *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, seehttps://docs.microsoft.com/rest/api/storageservices/undelete-blob.

func (*Client)WithSnapshot

func (b *Client) WithSnapshot(snapshotstring) (*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 (b *Client) WithVersionID(versionIDstring) (*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.

typeClientOptions

type ClientOptionsbase.ClientOptions

ClientOptions contains the optional parameters when creating a Client.

typeCopyFromURLOptions

type CopyFromURLOptions struct {// Optional. Used to set blob tags in various blob operations.BlobTags map[string]string// Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source.CopySourceAuthorization *string// File request Intent. Valid value is backup.FileRequestIntent *FileRequestIntentType// Specifies the date time when the blobs immutability policy is set to expire.ImmutabilityPolicyExpiry *time.Time// Specifies the immutability policy mode to set on the blob.ImmutabilityPolicyMode *ImmutabilityPolicySetting// Specified if a legal hold should be set on the blob.LegalHold *bool// Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value pairs are specified, the// operation will copy the metadata from the source blob or file to the destination// blob. If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and metadata// is not copied from the source blob or file. Note that beginning with// version 2009-09-19, metadata names must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers,// Blobs, and Metadata for more information.Metadata map[string]*string// Specify 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 *AccessTierSourceModifiedAccessConditions *SourceModifiedAccessConditionsBlobAccessConditions *AccessConditionsCPKScopeInfo *CPKScopeInfo}

CopyFromURLOptions contains the optional parameters for the Client.CopyFromURL method.

typeCopyFromURLResponse

type CopyFromURLResponse =generated.BlobClientCopyFromURLResponse

CopyFromURLResponse contains the response from method BlobClient.CopyFromURL.

typeCopyStatusType

type CopyStatusType =generated.CopyStatusType

CopyStatusType defines values for CopyStatusType

funcPossibleCopyStatusTypeValues

func PossibleCopyStatusTypeValues() []CopyStatusType

PossibleCopyStatusTypeValues returns the possible values for the CopyStatusType const type.

typeCreateSnapshotOptions

type CreateSnapshotOptions struct {Metadata         map[string]*stringAccessConditions *AccessConditionsCPKInfo          *CPKInfoCPKScopeInfo     *CPKScopeInfo}

CreateSnapshotOptions contains the optional parameters for the Client.CreateSnapshot method.

typeCreateSnapshotResponse

type CreateSnapshotResponse =generated.BlobClientCreateSnapshotResponse

CreateSnapshotResponse contains the response from method BlobClient.CreateSnapshot.

typeDeleteImmutabilityPolicyOptionsadded inv0.6.0

type DeleteImmutabilityPolicyOptions struct {}

DeleteImmutabilityPolicyOptions contains the optional parameters for the Client.DeleteImmutabilityPolicy method.

typeDeleteImmutabilityPolicyResponseadded inv0.6.0

type DeleteImmutabilityPolicyResponse =generated.BlobClientDeleteImmutabilityPolicyResponse

DeleteImmutabilityPolicyResponse contains the response from method BlobClient.DeleteImmutabilityPolicyResponse.

typeDeleteOptions

type DeleteOptions struct {// Required if the blob has associated snapshots. Specify one of the following two options: include: Delete the base blob// and all of its snapshots. only: Delete only the blob's snapshots and not the blob itself.DeleteSnapshots  *DeleteSnapshotsOptionTypeAccessConditions *AccessConditions// Setting DeleteType to DeleteTypePermanent will permanently delete soft-delete snapshot and/or version blobs.// WARNING: This is a dangerous operation and should not be used unless you know the implications. Please proceed// with caution.// For more information, seehttps://docs.microsoft.com/rest/api/storageservices/delete-blobBlobDeleteType *DeleteType}

DeleteOptions contains the optional parameters for the Client.Delete method.

typeDeleteResponse

type DeleteResponse =generated.BlobClientDeleteResponse

DeleteResponse contains the response from method BlobClient.Delete.

typeDeleteSnapshotsOptionType

type DeleteSnapshotsOptionType =generated.DeleteSnapshotsOptionType

DeleteSnapshotsOptionType defines values for DeleteSnapshotsOptionType

funcPossibleDeleteSnapshotsOptionTypeValues

func PossibleDeleteSnapshotsOptionTypeValues() []DeleteSnapshotsOptionType

PossibleDeleteSnapshotsOptionTypeValues returns the possible values for the DeleteSnapshotsOptionType const type.

typeDeleteType

type DeleteType =generated.DeleteType

DeleteType defines values for DeleteType.

funcPossibleDeleteTypeValues

func PossibleDeleteTypeValues() []DeleteType

PossibleDeleteTypeValues returns the possible values for the DeleteType const type.

typeDownloadBufferOptions

type DownloadBufferOptions struct {// Range specifies a range of bytes.  The default value is all bytes.RangeHTTPRange// BlockSize specifies the block size to use for each parallel download; the default size is DefaultDownloadBlockSize.BlockSizeint64// Progress is a function that is invoked periodically as bytes are received.Progress func(bytesTransferredint64)// BlobAccessConditions indicates the access conditions used when making HTTP GET requests against the blob.AccessConditions *AccessConditions// CPKInfo contains a group of parameters for client provided encryption key.CPKInfo *CPKInfo// CPKScopeInfo contains a group of parameters for client provided encryption scope.CPKScopeInfo *CPKScopeInfo// Concurrency indicates the maximum number of blocks to download in parallel (0=default).Concurrencyuint16// RetryReaderOptionsPerBlock is used when downloading each block.RetryReaderOptionsPerBlockRetryReaderOptions}

DownloadBufferOptions contains the optional parameters for the DownloadBuffer method.

typeDownloadFileOptions

type DownloadFileOptions struct {// Range specifies a range of bytes.  The default value is all bytes.RangeHTTPRange// BlockSize specifies the block size to use for each parallel download; the default size is DefaultDownloadBlockSize.BlockSizeint64// Progress is a function that is invoked periodically as bytes are received.Progress func(bytesTransferredint64)// BlobAccessConditions indicates the access conditions used when making HTTP GET requests against the blob.AccessConditions *AccessConditions// ClientProvidedKeyOptions indicates the client provided key by name and/or by value to encrypt/decrypt data.CPKInfo      *CPKInfoCPKScopeInfo *CPKScopeInfo// Concurrency indicates the maximum number of blocks to download in parallel.  The default value is 5.Concurrencyuint16// RetryReaderOptionsPerBlock is used when downloading each block.RetryReaderOptionsPerBlockRetryReaderOptions}

DownloadFileOptions contains the optional parameters for the DownloadFile method.

typeDownloadResponseadded inv1.0.0

type DownloadResponse =generated.BlobClientDownloadResponse

DownloadResponse contains the response from method BlobClient.Download.

typeDownloadStreamOptions

type DownloadStreamOptions struct {// When set to true and specified together with the Range, the service returns the MD5 hash for the range, as long as the// range is less than or equal to 4 MB in size.RangeGetContentMD5 *bool// Range specifies a range of bytes.  The default value is all bytes.RangeHTTPRangeAccessConditions *AccessConditionsCPKInfo          *CPKInfoCPKScopeInfo     *CPKScopeInfo}

DownloadStreamOptions contains the optional parameters for the Client.Download method.

typeDownloadStreamResponse

type DownloadStreamResponse struct {DownloadResponseObjectReplicationRules []ObjectReplicationPolicy// contains filtered or unexported fields}

DownloadStreamResponse contains the response from the DownloadStream method.To read from the stream, read from the Body field, or call the NewRetryReader method.

func (*DownloadStreamResponse)NewRetryReader

func (r *DownloadStreamResponse) NewRetryReader(ctxcontext.Context, options *RetryReaderOptions) *RetryReader

NewRetryReader constructs new RetryReader stream for reading data. If a connection fails whilereading, it will make additional requests to reestablish a connection and continue reading.Pass nil for options to accept the default options.Callers of this method should not access the DownloadStreamResponse.Body field.

typeEncryptionAlgorithmType

type EncryptionAlgorithmType =generated.EncryptionAlgorithmType

EncryptionAlgorithmType defines values for EncryptionAlgorithmType.

funcPossibleEncryptionAlgorithmTypeValues

func PossibleEncryptionAlgorithmTypeValues() []EncryptionAlgorithmType

PossibleEncryptionAlgorithmTypeValues returns the possible values for the EncryptionAlgorithmType const type.

typeFileRequestIntentTypeadded inv1.6.2

type FileRequestIntentType =generated.FileShareTokenIntent

FileRequestIntentType is file request intent with valid value as Backup

const (FileRequestIntentTypeBackupFileRequestIntentType = "backup")

funcPossibleFileRequestIntentTypeValuesadded inv1.6.2

func PossibleFileRequestIntentTypeValues() []FileRequestIntentType

PossibleFileRequestIntentTypeValues returns the possible values for the FileRequestIntentType const type.

typeGetAccountInfoOptionsadded inv1.1.0

type GetAccountInfoOptions struct {}

GetAccountInfoOptions provides set of options for Client.GetAccountInfo

typeGetAccountInfoResponseadded inv1.1.0

type GetAccountInfoResponse =generated.BlobClientGetAccountInfoResponse

GetAccountInfoResponse contains the response from method BlobClient.GetAccountInfo.

typeGetPropertiesOptions

type GetPropertiesOptions struct {AccessConditions *AccessConditionsCPKInfo          *CPKInfo}

GetPropertiesOptions contains the optional parameters for the Client.GetProperties method

typeGetPropertiesResponse

type GetPropertiesResponse =generated.BlobClientGetPropertiesResponse

GetPropertiesResponse contains the response from method BlobClient.GetProperties.

typeGetSASURLOptionsadded inv1.0.0

type GetSASURLOptions struct {StartTime *time.Time}

GetSASURLOptions contains the optional parameters for the Client.GetSASURL method.

typeGetTagsOptions

type GetTagsOptions struct {// The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve.Snapshot *string// The version id parameter is an opaque DateTime value that, when present, specifies the version of the blob to operate on.// It's for service version 2019-10-10 and newer.VersionID *stringBlobAccessConditions *AccessConditions}

GetTagsOptions contains the optional parameters for the Client.GetTags method.

typeGetTagsResponse

type GetTagsResponse =generated.BlobClientGetTagsResponse

GetTagsResponse contains the response from method BlobClient.GetTags.

typeHTTPHeaders

type HTTPHeaders =generated.BlobHTTPHeaders

HTTPHeaders contains a group of parameters for the BlobClient.SetHTTPHeaders method.

funcParseHTTPHeaders

func ParseHTTPHeaders(respGetPropertiesResponse)HTTPHeaders

ParseHTTPHeaders parses GetPropertiesResponse and returns HTTPHeaders.

typeHTTPRange

type HTTPRange =exported.HTTPRange

HTTPRange defines a range of bytes within an HTTP resource, starting at offset andending at offset+count. A zero-value HTTPRange indicates the entire resource. An HTTPRangewhich has an offset and zero value count indicates from the offset to the resource's end.

typeImmutabilityPolicyMode

type ImmutabilityPolicyMode =generated.ImmutabilityPolicyMode

ImmutabilityPolicyMode defines values for ImmutabilityPolicyMode

funcPossibleImmutabilityPolicyModeValues

func PossibleImmutabilityPolicyModeValues() []ImmutabilityPolicyMode

PossibleImmutabilityPolicyModeValues returns the possible values for the ImmutabilityPolicyMode const type.

typeImmutabilityPolicySetting

type ImmutabilityPolicySetting =generated.ImmutabilityPolicySetting

ImmutabilityPolicySetting returns the possible values for the ImmutabilityPolicySetting const type.

funcPossibleImmutabilityPolicySettingValues

func PossibleImmutabilityPolicySettingValues() []ImmutabilityPolicySetting

PossibleImmutabilityPolicySettingValues returns the possible values for the ImmutabilityPolicySetting const type.

typeLeaseAccessConditions

type LeaseAccessConditions =exported.LeaseAccessConditions

LeaseAccessConditions contains optional parameters to access leased entity.

typeModifiedAccessConditions

type ModifiedAccessConditions =exported.ModifiedAccessConditions

ModifiedAccessConditions contains a group of parameters for specifying access conditions.

typeObjectReplicationPolicy

type ObjectReplicationPolicy struct {PolicyID *stringRules    *[]ObjectReplicationRules}

ObjectReplicationPolicy are deserialized attributes.

typeObjectReplicationRules

type ObjectReplicationRules struct {RuleIDstringStatusstring}

ObjectReplicationRules struct

typeQueryFormatType

type QueryFormatType =generated.QueryFormatType

QueryFormatType - The quick query format type.

funcPossibleQueryFormatTypeValues

func PossibleQueryFormatTypeValues() []QueryFormatType

PossibleQueryFormatTypeValues returns the possible values for the QueryFormatType const type.

typeRehydratePriority

type RehydratePriority =generated.RehydratePriority

RehydratePriority - If an object is in rehydrate pending state then this header is returned with priority of rehydrate.Valid values are High and Standard.

funcPossibleRehydratePriorityValues

func PossibleRehydratePriorityValues() []RehydratePriority

PossibleRehydratePriorityValues returns the possible values for the RehydratePriority const type.

typeReleaseLeaseResponse

type ReleaseLeaseResponse =generated.BlobClientReleaseLeaseResponse

ReleaseLeaseResponse contains the response from method BlobClient.ReleaseLease.

typeRenewLeaseResponse

type RenewLeaseResponse =generated.BlobClientRenewLeaseResponse

RenewLeaseResponse contains the response from method BlobClient.RenewLease.

typeRetryReader

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

RetryReader attempts to read from response, and if there is a retry-able network errorreturned during reading, it will retry according to retry reader option through executinguser defined action with provided data to get a new response, and continue the overall reading processthrough reading from the new response.RetryReader implements the io.ReadCloser interface.

func (*RetryReader)Close

func (s *RetryReader) Close()error

Close retry reader

func (*RetryReader)Read

func (s *RetryReader) Read(p []byte) (nint, errerror)

Read from retry reader

typeRetryReaderOptions

type RetryReaderOptions struct {// MaxRetries specifies the maximum number of attempts a failed read will be retried// before producing an error.// The default value is three.MaxRetriesint32// OnFailedRead, when non-nil, is called after any failure to read. Expected usage is diagnostic logging.OnFailedRead func(failureCountint32, lastErrorerror, rngeHTTPRange, willRetrybool)// EarlyCloseAsError can be set to true to prevent retries after "read on closed response body". By default,// retryReader has the following special behaviour: closing the response body before it is all read is treated as a// retryable error. This is to allow callers to force a retry by closing the body from another goroutine (e.g. if the =// read is too slow, caller may want to force a retry in the hope that the retry will be quicker).  If// TreatEarlyCloseAsError is true, then retryReader's special behaviour is suppressed, and "read on closed body" is instead// treated as a fatal (non-retryable) error.// Note that setting TreatEarlyCloseAsError only guarantees that Closing will produce a fatal error if the Close happens// from the same "thread" (goroutine) as Read.  Concurrent Close calls from other goroutines may instead produce network errors// which will be retried.// The default value is false.EarlyCloseAsErrorbool// contains filtered or unexported fields}

RetryReaderOptions configures the retry reader's behavior.Zero-value fields will have their specified default values applied during use.This allows for modification of a subset of fields.

typeSetHTTPHeadersOptions

type SetHTTPHeadersOptions struct {AccessConditions *AccessConditions}

SetHTTPHeadersOptions contains the optional parameters for the Client.SetHTTPHeaders method.

typeSetHTTPHeadersResponse

type SetHTTPHeadersResponse =generated.BlobClientSetHTTPHeadersResponse

SetHTTPHeadersResponse contains the response from method BlobClient.SetHTTPHeaders.

typeSetImmutabilityPolicyOptionsadded inv0.6.0

type SetImmutabilityPolicyOptions struct {// Specifies the immutability policy mode to set on the blob. Possible values to set include: "Locked", "Unlocked".// "Mutable" can only be returned by service, don't set to "Mutable". If mode is not set - it will default to Unlocked.Mode                     *ImmutabilityPolicySettingModifiedAccessConditions *ModifiedAccessConditions}

SetImmutabilityPolicyOptions contains the parameter for Client.SetImmutabilityPolicy

typeSetImmutabilityPolicyResponseadded inv0.6.0

type SetImmutabilityPolicyResponse =generated.BlobClientSetImmutabilityPolicyResponse

SetImmutabilityPolicyResponse contains the response from method BlobClient.SetImmutabilityPolicy.

typeSetLegalHoldOptionsadded inv0.6.0

type SetLegalHoldOptions struct {}

SetLegalHoldOptions contains the optional parameters for the Client.SetLegalHold method.

typeSetLegalHoldResponseadded inv0.6.0

type SetLegalHoldResponse =generated.BlobClientSetLegalHoldResponse

SetLegalHoldResponse contains the response from method BlobClient.SetLegalHold.

typeSetMetadataOptions

type SetMetadataOptions struct {AccessConditions *AccessConditionsCPKInfo          *CPKInfoCPKScopeInfo     *CPKScopeInfo}

SetMetadataOptions provides set of configurations for Set Metadata on blob operation

typeSetMetadataResponse

type SetMetadataResponse =generated.BlobClientSetMetadataResponse

SetMetadataResponse contains the response from method BlobClient.SetMetadata.

typeSetTagsOptions

type SetTagsOptions struct {// The version id parameter is an opaque DateTime value that, when present,// specifies the version of the blob to operate on. It's for service version 2019-10-10 and newer.VersionID *string// Optional header, Specifies the transactional crc64 for the body, to be validated by the service.TransactionalContentCRC64 []byte// Optional header, Specifies the transactional md5 for the body, to be validated by the service.TransactionalContentMD5 []byteAccessConditions *AccessConditions}

SetTagsOptions contains the optional parameters for the Client.SetTags method.

typeSetTagsResponse

type SetTagsResponse =generated.BlobClientSetTagsResponse

SetTagsResponse contains the response from method BlobClient.SetTags.

typeSetTierOptions

type SetTierOptions struct {// Optional: Indicates the priority with which to rehydrate an archived blob.RehydratePriority *RehydratePriorityAccessConditions *AccessConditions}

SetTierOptions contains the optional parameters for the Client.SetTier method.

typeSetTierResponse

type SetTierResponse =generated.BlobClientSetTierResponse

SetTierResponse contains the response from method BlobClient.SetTier.

typeSharedKeyCredential

type SharedKeyCredential =exported.SharedKeyCredential

SharedKeyCredential contains an account's name and its primary or secondary key.

funcNewSharedKeyCredential

func NewSharedKeyCredential(accountName, accountKeystring) (*SharedKeyCredential,error)

NewSharedKeyCredential creates an immutable SharedKeyCredential containing thestorage account's name and either its primary or secondary key.

typeSourceContentValidationTypeadded inv0.6.0

type SourceContentValidationType interface {Apply(generated.SourceContentSetter)// contains filtered or unexported methods}

SourceContentValidationType abstracts the various mechanisms used to validate source content.This interface is not publicly implementable.

typeSourceContentValidationTypeCRC64added inv0.6.0

type SourceContentValidationTypeCRC64 []byte

SourceContentValidationTypeCRC64 is a SourceContentValidationType used to provide a precomputed CRC64.

func (SourceContentValidationTypeCRC64)Applyadded inv0.6.0

Apply implements the SourceContentValidationType interface for type SourceContentValidationTypeCRC64.

typeSourceContentValidationTypeMD5added inv0.6.0

type SourceContentValidationTypeMD5 []byte

SourceContentValidationTypeMD5 is a SourceContentValidationType used to provide a precomputed MD5.

func (SourceContentValidationTypeMD5)Applyadded inv0.6.0

Apply implements the SourceContentValidationType interface for type SourceContentValidationTypeMD5.

typeSourceModifiedAccessConditions

type SourceModifiedAccessConditions =generated.SourceModifiedAccessConditions

SourceModifiedAccessConditions contains a group of parameters for the BlobClient.StartCopyFromURL method.

typeStartCopyFromURLOptions

type StartCopyFromURLOptions struct {// Specifies the date time when the blobs immutability policy is set to expire.ImmutabilityPolicyExpiry *time.Time// Specifies the immutability policy mode to set on the blob.ImmutabilityPolicyMode *ImmutabilityPolicySetting// Specified if a legal hold should be set on the blob.LegalHold *bool// Optional. Used to set blob tags in various blob operations.BlobTags map[string]string// Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value pairs are specified, the// operation will copy the metadata from the source blob or file to the destination blob. If one or more name-value pairs// are specified, the destination blob is created with the specified metadata, and metadata is not copied from the source// blob or file. Note that beginning with version 2009-09-19, metadata names must adhere to the naming rules for C# identifiers.// See Naming and Referencing Containers, Blobs, and Metadata for more information.Metadata map[string]*string// Optional: Indicates the priority with which to rehydrate an archived blob.RehydratePriority *RehydratePriority// Overrides the sealed state of the destination blob. Service version 2019-12-12 and newer.SealBlob *bool// Optional. Indicates the tier to be set on the blob.Tier *AccessTierSourceModifiedAccessConditions *SourceModifiedAccessConditionsAccessConditions *AccessConditions}

StartCopyFromURLOptions contains the optional parameters for the Client.StartCopyFromURL method.

typeStartCopyFromURLResponse

type StartCopyFromURLResponse =generated.BlobClientStartCopyFromURLResponse

StartCopyFromURLResponse contains the response from method BlobClient.StartCopyFromURL.

typeTags

type Tags =generated.BlobTag

Tags represent map of blob index tags

typeTransferValidationTypeadded inv0.6.0

type TransferValidationType =exported.TransferValidationType

TransferValidationType abstracts the various mechanisms used to verify a transfer.

funcTransferValidationTypeComputeCRC64added inv0.6.0

func TransferValidationTypeComputeCRC64()TransferValidationType

TransferValidationTypeComputeCRC64 is a TransferValidationType that indicates a CRC64 should be computed during transfer.

typeTransferValidationTypeCRC64added inv0.6.0

type TransferValidationTypeCRC64 =exported.TransferValidationTypeCRC64

TransferValidationTypeCRC64 is a TransferValidationType used to provide a precomputed CRC64.

typeTransferValidationTypeMD5added inv0.6.0

type TransferValidationTypeMD5 =exported.TransferValidationTypeMD5

TransferValidationTypeMD5 is a TransferValidationType used to provide a precomputed MD5.

typeURLParts

type URLParts =sas.URLParts

URLParts object represents the components that make up an Azure Storage Container/Blob URL.NOTE: Changing any SAS-related field requires computing a new SAS signature.

funcParseURL

func ParseURL(ustring) (URLParts,error)

ParseURL parses a URL initializing URLParts' fields including any SAS-related & snapshot query parameters. Any otherquery parameters remain in the UnparsedParams field. This method overwrites all fields in the URLParts object.

Example

This example demonstrates splitting a URL into its parts so you can examine and modify the URL in an Azure Storage fluent way.

package mainimport ("fmt""github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob")func main() {// Here is an example of a blob snapshot.u := "https://myaccount.blob.core.windows.net/mycontainter/ReadMe.txt?" +"snapshot=2011-03-09T01:42:34Z&" +"sv=2015-02-21&sr=b&st=2111-01-09T01:42:34.936Z&se=2222-03-09T01:42:34.936Z&sp=rw&sip=168.1.5.60-168.1.5.70&" +"spr=https,http&si=myIdentifier&ss=bf&srt=s&sig=92836758923659283652983562=="// Breaking the URL down into it's parts by conversion to URLPartsparts, _ := blob.ParseURL(u)// The URLParts allows access to individual portions of a Blob URLfmt.Printf("Host: %s\nContainerName: %s\nBlobName: %s\nSnapshot: %s\n", parts.Host, parts.ContainerName, parts.BlobName, parts.Snapshot)fmt.Printf("Version: %s\nResource: %s\nStartTime: %s\nExpiryTime: %s\nPermissions: %s\n", parts.SAS.Version(), parts.SAS.Resource(), parts.SAS.StartTime(), parts.SAS.ExpiryTime(), parts.SAS.Permissions())}

typeUndeleteOptions

type UndeleteOptions struct {}

UndeleteOptions contains the optional parameters for the Client.Undelete method.

typeUndeleteResponse

type UndeleteResponse =generated.BlobClientUndeleteResponse

UndeleteResponse contains the response from method BlobClient.Undelete.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp