blob package - github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob - Go Packages (original) (raw)
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 main
import ( "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 returned
snapTime := "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)
}
Output:
This example shows how to create a blob with metadata, read blob metadata, and update a blob's read-only properties and metadata.
package main
import ( "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 client
u := 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 metadata
get, err := blobClient.GetProperties(context.TODO(), nil)
handleError(err)
// Show some of the blob's read-only properties
fmt.Printf("BlobType: %s\nETag: %s\nLastModified: %s\n", *get.BlobType, *get.ETag, *get.LastModified)
// Show the blob's metadata
if 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 blob
get.Metadata["editor"] = to.Ptr("Grant")
_, err = blobClient.SetMetadata(context.TODO(), get.Metadata, nil)
handleError(err)
}
Output:
This example shows how to copy a source document on the Internet to a blob.
package main
import ( "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.CopyID
copyStatus := *startCopy.CopyStatus
for 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)
}
Output:
- func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error)
- func NewClientFromConnectionString(connectionString, containerName, blobName string, options *ClientOptions) (*Client, error)
- func NewClientWithNoCredential(blobURL string, options *ClientOptions) (*Client, error)
- func NewClientWithSharedKeyCredential(blobURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error)
- func (b *Client) AbortCopyFromURL(ctx context.Context, copyID string, options *AbortCopyFromURLOptions) (AbortCopyFromURLResponse, error)
- func (b *Client) CopyFromURL(ctx context.Context, copySource string, options *CopyFromURLOptions) (CopyFromURLResponse, error)
- func (b *Client) CreateSnapshot(ctx context.Context, options *CreateSnapshotOptions) (CreateSnapshotResponse, error)
- func (b *Client) Delete(ctx context.Context, o *DeleteOptions) (DeleteResponse, error)
- func (b *Client) DeleteImmutabilityPolicy(ctx context.Context, options *DeleteImmutabilityPolicyOptions) (DeleteImmutabilityPolicyResponse, error)
- func (b *Client) DownloadBuffer(ctx context.Context, buffer []byte, o *DownloadBufferOptions) (int64, error)
- func (b *Client) DownloadFile(ctx context.Context, file *os.File, o *DownloadFileOptions) (int64, error)
- func (b *Client) DownloadStream(ctx context.Context, o *DownloadStreamOptions) (DownloadStreamResponse, error)
- func (b *Client) GetAccountInfo(ctx context.Context, o *GetAccountInfoOptions) (GetAccountInfoResponse, error)
- func (b *Client) GetProperties(ctx context.Context, options *GetPropertiesOptions) (GetPropertiesResponse, error)
- func (b *Client) GetSASURL(permissions sas.BlobPermissions, expiry time.Time, o *GetSASURLOptions) (string, error)
- func (b *Client) GetTags(ctx context.Context, options *GetTagsOptions) (GetTagsResponse, error)
- func (b *Client) SetHTTPHeaders(ctx context.Context, httpHeaders HTTPHeaders, o *SetHTTPHeadersOptions) (SetHTTPHeadersResponse, error)
- func (b *Client) SetImmutabilityPolicy(ctx context.Context, expiryTime time.Time, ...) (SetImmutabilityPolicyResponse, error)
- func (b *Client) SetLegalHold(ctx context.Context, legalHold bool, options *SetLegalHoldOptions) (SetLegalHoldResponse, error)
- func (b *Client) SetMetadata(ctx context.Context, metadata map[string]*string, o *SetMetadataOptions) (SetMetadataResponse, error)
- func (b *Client) SetTags(ctx context.Context, tags map[string]string, options *SetTagsOptions) (SetTagsResponse, error)
- func (b *Client) SetTier(ctx context.Context, tier AccessTier, o *SetTierOptions) (SetTierResponse, error)
- func (b *Client) StartCopyFromURL(ctx context.Context, copySource string, options *StartCopyFromURLOptions) (StartCopyFromURLResponse, error)
- func (b *Client) URL() string
- func (b *Client) Undelete(ctx context.Context, o *UndeleteOptions) (UndeleteResponse, error)
- func (b *Client) WithSnapshot(snapshot string) (*Client, error)
- func (b *Client) WithVersionID(versionID string) (*Client, error)
const ReadOnClosedBodyMessage = "read on closed response body"
ReadOnClosedBodyMessage of retry reader
This section is empty.
This section is empty.
type AbortCopyFromURLOptions struct { LeaseAccessConditions *LeaseAccessConditions }
AbortCopyFromURLOptions contains the optional parameters for the Client.AbortCopyFromURL method.
AbortCopyFromURLResponse contains the response from method BlobClient.AbortCopyFromURL.
AccessConditions identifies blob-specific access conditions which you optionally set.
AccessTier defines values for Blob Access Tier.
func PossibleAccessTierValues() []AccessTier
PossibleAccessTierValues returns the possible values for the AccessTier const type.
AcquireLeaseResponse contains the response from method BlobClient.AcquireLease.
ArchiveStatus defines values for ArchiveStatus.
func PossibleArchiveStatusValues() []ArchiveStatus
PossibleArchiveStatusValues returns the possible values for the ArchiveStatus const type.
BlobType defines values for BlobType
func PossibleBlobTypeValues() []BlobType
PossibleBlobTypeValues returns the possible values for the BlobType const type.
BreakLeaseResponse contains the response from method BlobClient.BreakLease.
CPKInfo contains a group of parameters for client provided encryption key.
CPKScopeInfo contains a group of parameters for client provided encryption scope.
ChangeLeaseResponse contains the response from method BlobClient.ChangeLease.
Client represents a URL to an Azure Storage blob; the blob may be a block blob, append blob, or page blob.
NewClient creates an instance of Client with the specified values.
- blobURL - the URL of the blob e.g. https://.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(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(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://.blob.core.windows.net/container/blob.txt?
- options - client options; pass nil to accept the default values
func NewClientWithSharedKeyCredential(blobURL string, 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://.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
DownloadBuffer downloads an Azure blob to a buffer with parallel.
DownloadFile downloads an Azure blob to a local file. The file would be truncated if the size doesn't match.
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.
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 tiers see https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers.
URL returns the URL endpoint used by the Client object.
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.
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.
ClientOptions contains the optional parameters when creating a Client.
type CopyFromURLOptions struct {
BlobTags map[[string](/builtin#string)][string](/builtin#string)
CopySourceAuthorization *[string](/builtin#string)
ImmutabilityPolicyExpiry *[time](/time).[Time](/time#Time)
ImmutabilityPolicyMode *[ImmutabilityPolicySetting](#ImmutabilityPolicySetting)
LegalHold *[bool](/builtin#bool)
Metadata map[[string](/builtin#string)]*[string](/builtin#string)
SourceContentMD5 [][byte](/builtin#byte)
Tier *[AccessTier](#AccessTier)
SourceModifiedAccessConditions *[SourceModifiedAccessConditions](#SourceModifiedAccessConditions)
BlobAccessConditions *[AccessConditions](#AccessConditions)
CPKScopeInfo *[CPKScopeInfo](#CPKScopeInfo)
}
CopyFromURLOptions contains the optional parameters for the Client.CopyFromURL method.
CopyFromURLResponse contains the response from method BlobClient.CopyFromURL.
CopyStatusType defines values for CopyStatusType
func PossibleCopyStatusTypeValues() []CopyStatusType
PossibleCopyStatusTypeValues returns the possible values for the CopyStatusType const type.
type CreateSnapshotOptions struct { Metadata map[string]*string AccessConditions *AccessConditions CPKInfo *CPKInfo CPKScopeInfo *CPKScopeInfo }
CreateSnapshotOptions contains the optional parameters for the Client.CreateSnapshot method.
CreateSnapshotResponse contains the response from method BlobClient.CreateSnapshot.
type DeleteImmutabilityPolicyOptions struct { }
DeleteImmutabilityPolicyOptions contains the optional parameters for the Client.DeleteImmutabilityPolicy method.
DeleteImmutabilityPolicyResponse contains the response from method BlobClient.DeleteImmutabilityPolicyResponse.
type DeleteOptions struct {
DeleteSnapshots *[DeleteSnapshotsOptionType](#DeleteSnapshotsOptionType)
AccessConditions *[AccessConditions](#AccessConditions)
BlobDeleteType *[DeleteType](#DeleteType)
}
DeleteOptions contains the optional parameters for the Client.Delete method.
DeleteResponse contains the response from method BlobClient.Delete.
DeleteSnapshotsOptionType defines values for DeleteSnapshotsOptionType
func PossibleDeleteSnapshotsOptionTypeValues() []DeleteSnapshotsOptionType
PossibleDeleteSnapshotsOptionTypeValues returns the possible values for the DeleteSnapshotsOptionType const type.
DeleteType defines values for DeleteType.
func PossibleDeleteTypeValues() []DeleteType
PossibleDeleteTypeValues returns the possible values for the DeleteType const type.
type DownloadBufferOptions struct {
Range [HTTPRange](#HTTPRange)
BlockSize [int64](/builtin#int64)
Progress func(bytesTransferred [int64](/builtin#int64))
AccessConditions *[AccessConditions](#AccessConditions)
CPKInfo *[CPKInfo](#CPKInfo)
CPKScopeInfo *[CPKScopeInfo](#CPKScopeInfo)
Concurrency [uint16](/builtin#uint16)
RetryReaderOptionsPerBlock [RetryReaderOptions](#RetryReaderOptions)
}
DownloadBufferOptions contains the optional parameters for the DownloadBuffer method.
type DownloadFileOptions struct {
Range [HTTPRange](#HTTPRange)
BlockSize [int64](/builtin#int64)
Progress func(bytesTransferred [int64](/builtin#int64))
AccessConditions *[AccessConditions](#AccessConditions)
CPKInfo *[CPKInfo](#CPKInfo)
CPKScopeInfo *[CPKScopeInfo](#CPKScopeInfo)
Concurrency [uint16](/builtin#uint16)
RetryReaderOptionsPerBlock [RetryReaderOptions](#RetryReaderOptions)
}
DownloadFileOptions contains the optional parameters for the DownloadFile method.
DownloadResponse contains the response from method BlobClient.Download.
type DownloadStreamOptions struct {
RangeGetContentMD5 *[bool](/builtin#bool)
Range [HTTPRange](#HTTPRange)
AccessConditions *[AccessConditions](#AccessConditions)
CPKInfo *[CPKInfo](#CPKInfo)
CPKScopeInfo *[CPKScopeInfo](#CPKScopeInfo)
}
DownloadStreamOptions contains the optional parameters for the Client.Download method.
type DownloadStreamResponse struct { DownloadResponse ObjectReplicationRules []ObjectReplicationPolicy
}
DownloadStreamResponse contains the response from the DownloadStream method. To read from the stream, read from the Body field, or call the NewRetryReader method.
NewRetryReader constructs new RetryReader stream for reading data. If a connection fails while reading, 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.
EncryptionAlgorithmType defines values for EncryptionAlgorithmType.
func PossibleEncryptionAlgorithmTypeValues() []EncryptionAlgorithmType
PossibleEncryptionAlgorithmTypeValues returns the possible values for the EncryptionAlgorithmType const type.
type GetAccountInfoOptions struct { }
GetAccountInfoOptions provides set of options for Client.GetAccountInfo
GetAccountInfoResponse contains the response from method BlobClient.GetAccountInfo.
type GetPropertiesOptions struct { AccessConditions *AccessConditions CPKInfo *CPKInfo }
GetPropertiesOptions contains the optional parameters for the Client.GetProperties method
GetPropertiesResponse contains the response from method BlobClient.GetProperties.
type GetSASURLOptions struct { StartTime *time.Time }
GetSASURLOptions contains the optional parameters for the Client.GetSASURL method.
type GetTagsOptions struct {
Snapshot *[string](/builtin#string)
VersionID *[string](/builtin#string)
BlobAccessConditions *[AccessConditions](#AccessConditions)
}
GetTagsOptions contains the optional parameters for the Client.GetTags method.
GetTagsResponse contains the response from method BlobClient.GetTags.
HTTPHeaders contains a group of parameters for the BlobClient.SetHTTPHeaders method.
func ParseHTTPHeaders(resp GetPropertiesResponse) HTTPHeaders
ParseHTTPHeaders parses GetPropertiesResponse and returns HTTPHeaders.
HTTPRange defines a range of bytes within an HTTP resource, starting at offset and ending at offset+count. A zero-value HTTPRange indicates the entire resource. An HTTPRange which has an offset and zero value count indicates from the offset to the resource's end.
ImmutabilityPolicyMode defines values for ImmutabilityPolicyMode
func PossibleImmutabilityPolicyModeValues() []ImmutabilityPolicyMode
PossibleImmutabilityPolicyModeValues returns the possible values for the ImmutabilityPolicyMode const type.
ImmutabilityPolicySetting returns the possible values for the ImmutabilityPolicySetting const type.
func PossibleImmutabilityPolicySettingValues() []ImmutabilityPolicySetting
PossibleImmutabilityPolicySettingValues returns the possible values for the ImmutabilityPolicySetting const type.
LeaseAccessConditions contains optional parameters to access leased entity.
ModifiedAccessConditions contains a group of parameters for specifying access conditions.
type ObjectReplicationPolicy struct { PolicyID *string Rules *[]ObjectReplicationRules }
ObjectReplicationPolicy are deserialized attributes.
type ObjectReplicationRules struct { RuleID string Status string }
ObjectReplicationRules struct
QueryFormatType - The quick query format type.
func PossibleQueryFormatTypeValues() []QueryFormatType
PossibleQueryFormatTypeValues returns the possible values for the QueryFormatType const type.
RehydratePriority - If an object is in rehydrate pending state then this header is returned with priority of rehydrate. Valid values are High and Standard.
func PossibleRehydratePriorityValues() []RehydratePriority
PossibleRehydratePriorityValues returns the possible values for the RehydratePriority const type.
ReleaseLeaseResponse contains the response from method BlobClient.ReleaseLease.
RenewLeaseResponse contains the response from method BlobClient.RenewLease.
type RetryReader struct {
}
RetryReader attempts to read from response, and if there is a retry-able network error returned during reading, it will retry according to retry reader option through executing user defined action with provided data to get a new response, and continue the overall reading process through reading from the new response. RetryReader implements the io.ReadCloser interface.
type RetryReaderOptions struct {
MaxRetries [int32](/builtin#int32)
OnFailedRead func(failureCount [int32](/builtin#int32), lastError [error](/builtin#error), rnge [HTTPRange](#HTTPRange), willRetry [bool](/builtin#bool))
EarlyCloseAsError [bool](/builtin#bool)
}
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.
type SetHTTPHeadersOptions struct { }
SetHTTPHeadersOptions contains the optional parameters for the Client.SetHTTPHeaders method.
SetHTTPHeadersResponse contains the response from method BlobClient.SetHTTPHeaders.
type SetImmutabilityPolicyOptions struct {
Mode *[ImmutabilityPolicySetting](#ImmutabilityPolicySetting)
ModifiedAccessConditions *[ModifiedAccessConditions](#ModifiedAccessConditions)
}
SetImmutabilityPolicyOptions contains the parameter for Client.SetImmutabilityPolicy
SetImmutabilityPolicyResponse contains the response from method BlobClient.SetImmutabilityPolicy.
type SetLegalHoldOptions struct { }
SetLegalHoldOptions contains the optional parameters for the Client.SetLegalHold method.
SetLegalHoldResponse contains the response from method BlobClient.SetLegalHold.
type SetMetadataOptions struct { AccessConditions *AccessConditions CPKInfo *CPKInfo CPKScopeInfo *CPKScopeInfo }
SetMetadataOptions provides set of configurations for Set Metadata on blob operation
SetMetadataResponse contains the response from method BlobClient.SetMetadata.
type SetTagsOptions struct {
VersionID *[string](/builtin#string)
TransactionalContentCRC64 [][byte](/builtin#byte)
TransactionalContentMD5 [][byte](/builtin#byte)
AccessConditions *[AccessConditions](#AccessConditions)
}
SetTagsOptions contains the optional parameters for the Client.SetTags method.
SetTagsResponse contains the response from method BlobClient.SetTags.
type SetTierOptions struct {
RehydratePriority *[RehydratePriority](#RehydratePriority)
AccessConditions *[AccessConditions](#AccessConditions)
}
SetTierOptions contains the optional parameters for the Client.SetTier method.
SetTierResponse contains the response from method BlobClient.SetTier.
SharedKeyCredential contains an account's name and its primary or secondary key.
func NewSharedKeyCredential(accountName, accountKey string) (*SharedKeyCredential, error)
NewSharedKeyCredential creates an immutable SharedKeyCredential containing the storage account's name and either its primary or secondary key.
type SourceContentValidationType ¶ added in v0.6.0
SourceContentValidationType abstracts the various mechanisms used to validate source content. This interface is not publicly implementable.
type SourceContentValidationTypeCRC64 ¶ added in v0.6.0
type SourceContentValidationTypeCRC64 []byte
SourceContentValidationTypeCRC64 is a SourceContentValidationType used to provide a precomputed CRC64.
func (SourceContentValidationTypeCRC64) Apply ¶ added in v0.6.0
Apply implements the SourceContentValidationType interface for type SourceContentValidationTypeCRC64.
type SourceContentValidationTypeMD5 ¶ added in v0.6.0
type SourceContentValidationTypeMD5 []byte
SourceContentValidationTypeMD5 is a SourceContentValidationType used to provide a precomputed MD5.
func (SourceContentValidationTypeMD5) Apply ¶ added in v0.6.0
Apply implements the SourceContentValidationType interface for type SourceContentValidationTypeMD5.
SourceModifiedAccessConditions contains a group of parameters for the BlobClient.StartCopyFromURL method.
type StartCopyFromURLOptions struct {
ImmutabilityPolicyExpiry *[time](/time).[Time](/time#Time)
ImmutabilityPolicyMode *[ImmutabilityPolicySetting](#ImmutabilityPolicySetting)
LegalHold *[bool](/builtin#bool)
BlobTags map[[string](/builtin#string)][string](/builtin#string)
Metadata map[[string](/builtin#string)]*[string](/builtin#string)
RehydratePriority *[RehydratePriority](#RehydratePriority)
SealBlob *[bool](/builtin#bool)
Tier *[AccessTier](#AccessTier)
SourceModifiedAccessConditions *[SourceModifiedAccessConditions](#SourceModifiedAccessConditions)
AccessConditions *[AccessConditions](#AccessConditions)
}
StartCopyFromURLOptions contains the optional parameters for the Client.StartCopyFromURL method.
StartCopyFromURLResponse contains the response from method BlobClient.StartCopyFromURL.
Tags represent map of blob index tags
TransferValidationType abstracts the various mechanisms used to verify a transfer.
func TransferValidationTypeComputeCRC64() TransferValidationType
TransferValidationTypeComputeCRC64 is a TransferValidationType that indicates a CRC64 should be computed during transfer.
TransferValidationTypeCRC64 is a TransferValidationType used to provide a precomputed CRC64.
TransferValidationTypeMD5 is a TransferValidationType used to provide a precomputed MD5.
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.
ParseURL parses a URL initializing URLParts' fields including any SAS-related & snapshot query parameters. Any other query parameters remain in the UnparsedParams field. This method overwrites all fields in the URLParts object.
This example demonstrates splitting a URL into its parts so you can examine and modify the URL in an Azure Storage fluent way.
package main
import ( "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 URLParts
parts, _ := blob.ParseURL(u)
// The URLParts allows access to individual portions of a Blob URL
fmt.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())
}
Output:
type UndeleteOptions struct { }
UndeleteOptions contains the optional parameters for the Client.Undelete method.
UndeleteResponse contains the response from method BlobClient.Undelete.