[BlobSDK][GO] Feature: Set Blob Tags/Get Blob Tags/Find blobs by tags (#209)
* Get Blob Tag/Set Blob Tag/Find Blob by Tag * Get Blob Tag/Set Blob Tag/Find Blob by Tag + Writing Tests * Bug Fix * Code Refactoring * Code Refactoring 2 * Test case for findblobsbytags * Minor Fix 1 * rectified blob tags comment corresponding to ifTags param
This commit is contained in:
Родитель
a0589d15da
Коммит
8327933c9a
|
@ -17,7 +17,7 @@ import (
|
|||
// This allows us to provide a local implementation that fakes the server for hermetic testing.
|
||||
type blockWriter interface {
|
||||
StageBlock(context.Context, string, io.ReadSeeker, LeaseAccessConditions, []byte) (*BlockBlobStageBlockResponse, error)
|
||||
CommitBlockList(context.Context, []string, BlobHTTPHeaders, Metadata, BlobAccessConditions, AccessTierType) (*BlockBlobCommitBlockListResponse, error)
|
||||
CommitBlockList(context.Context, []string, BlobHTTPHeaders, Metadata, BlobAccessConditions, AccessTierType, BlobTagsMap) (*BlockBlobCommitBlockListResponse, error)
|
||||
}
|
||||
|
||||
// copyFromReader copies a source io.Reader to blob storage using concurrent uploads.
|
||||
|
@ -201,7 +201,7 @@ func (c *copier) close() error {
|
|||
}
|
||||
|
||||
var err error
|
||||
c.result, err = c.to.CommitBlockList(c.ctx, c.id.issued(), c.o.BlobHTTPHeaders, c.o.Metadata, c.o.AccessConditions, c.o.BlobAccessTier)
|
||||
c.result, err = c.to.CommitBlockList(c.ctx, c.id.issued(), c.o.BlobHTTPHeaders, c.o.Metadata, c.o.AccessConditions, c.o.BlobAccessTier, c.o.BlobTagsMap)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ func (f *fakeBlockWriter) StageBlock(ctx context.Context, blockID string, r io.R
|
|||
return &BlockBlobStageBlockResponse{}, nil
|
||||
}
|
||||
|
||||
func (f *fakeBlockWriter) CommitBlockList(ctx context.Context, blockIDs []string, headers BlobHTTPHeaders, meta Metadata, access BlobAccessConditions, tier AccessTierType) (*BlockBlobCommitBlockListResponse, error) {
|
||||
func (f *fakeBlockWriter) CommitBlockList(ctx context.Context, blockIDs []string, headers BlobHTTPHeaders, meta Metadata, access BlobAccessConditions, tier AccessTierType, blobTagsMap BlobTagsMap) (*BlockBlobCommitBlockListResponse, error) {
|
||||
dst, err := os.OpenFile(filepath.Join(f.path, finalFileName), os.O_CREATE+os.O_WRONLY, 0600)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
package azblob
|
|
@ -58,6 +58,9 @@ type UploadToBlockBlobOptions struct {
|
|||
// BlobAccessTier indicates the tier of blob
|
||||
BlobAccessTier AccessTierType
|
||||
|
||||
// BlobTagsStg
|
||||
BlobTagsMap BlobTagsMap
|
||||
|
||||
// Parallelism indicates the maximum number of blocks to upload in parallel (0=default)
|
||||
Parallelism uint16
|
||||
}
|
||||
|
@ -89,7 +92,7 @@ func UploadBufferToBlockBlob(ctx context.Context, b []byte,
|
|||
if o.Progress != nil {
|
||||
body = pipeline.NewRequestBodyProgress(body, o.Progress)
|
||||
}
|
||||
return blockBlobURL.Upload(ctx, body, o.BlobHTTPHeaders, o.Metadata, o.AccessConditions, o.BlobAccessTier)
|
||||
return blockBlobURL.Upload(ctx, body, o.BlobHTTPHeaders, o.Metadata, o.AccessConditions, o.BlobAccessTier, o.BlobTagsMap)
|
||||
}
|
||||
|
||||
var numBlocks = uint16(((bufferSize - 1) / o.BlockSize) + 1)
|
||||
|
@ -133,7 +136,7 @@ func UploadBufferToBlockBlob(ctx context.Context, b []byte,
|
|||
return nil, err
|
||||
}
|
||||
// All put blocks were successful, call Put Block List to finalize the blob
|
||||
return blockBlobURL.CommitBlockList(ctx, blockIDList, o.BlobHTTPHeaders, o.Metadata, o.AccessConditions, o.BlobAccessTier)
|
||||
return blockBlobURL.CommitBlockList(ctx, blockIDList, o.BlobHTTPHeaders, o.Metadata, o.AccessConditions, o.BlobAccessTier, o.BlobTagsMap)
|
||||
}
|
||||
|
||||
// UploadFileToBlockBlob uploads a file in blocks to a block blob.
|
||||
|
@ -367,6 +370,7 @@ type UploadStreamToBlockBlobOptions struct {
|
|||
Metadata Metadata
|
||||
AccessConditions BlobAccessConditions
|
||||
BlobAccessTier AccessTierType
|
||||
BlobTagsMap BlobTagsMap
|
||||
}
|
||||
|
||||
func (u *UploadStreamToBlockBlobOptions) defaults() {
|
||||
|
|
|
@ -56,17 +56,18 @@ func (ab AppendBlobURL) GetAccountInfo(ctx context.Context) (*BlobGetAccountInfo
|
|||
|
||||
// Create creates a 0-length append blob. Call AppendBlock to append data to an append blob.
|
||||
// For more information, see https://docs.microsoft.com/rest/api/storageservices/put-blob.
|
||||
func (ab AppendBlobURL) Create(ctx context.Context, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions) (*AppendBlobCreateResponse, error) {
|
||||
func (ab AppendBlobURL) Create(ctx context.Context, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, blobTagsMap BlobTagsMap) (*AppendBlobCreateResponse, error) {
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch := ac.ModifiedAccessConditions.pointers()
|
||||
blobTagsString := SerializeBlobTagsHeader(blobTagsMap)
|
||||
return ab.abClient.Create(ctx, 0, nil,
|
||||
&h.ContentType, &h.ContentEncoding, &h.ContentLanguage, h.ContentMD5,
|
||||
&h.CacheControl, metadata, ac.LeaseAccessConditions.pointers(), &h.ContentDisposition,
|
||||
nil, nil, EncryptionAlgorithmNone, // CPK-V
|
||||
nil, // CPK-N
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil,
|
||||
nil, // Blob tags
|
||||
blobTagsString, // Blob tags
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -89,7 +90,7 @@ func (ab AppendBlobURL) AppendBlock(ctx context.Context, body io.ReadSeeker, ac
|
|||
nil, nil, EncryptionAlgorithmNone, // CPK
|
||||
nil, // CPK-N
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
|
@ -106,7 +107,7 @@ func (ab AppendBlobURL) AppendBlockFromURL(ctx context.Context, sourceURL url.UR
|
|||
destinationAccessConditions.LeaseAccessConditions.pointers(),
|
||||
ifMaxSizeLessThanOrEqual, ifAppendPositionEqual,
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatchETag, sourceIfNoneMatchETag, nil)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@ package azblob
|
|||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
|
||||
"github.com/Azure/azure-pipeline-go/pipeline"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// A BlobURL represents a URL to an Azure Storage blob; the blob may be a block blob, append blob, or page blob.
|
||||
|
@ -12,6 +12,8 @@ type BlobURL struct {
|
|||
blobClient blobClient
|
||||
}
|
||||
|
||||
type BlobTagsMap map[string]string
|
||||
|
||||
var DefaultAccessTier AccessTierType = AccessTierNone
|
||||
var DefaultPremiumBlobAccessTier PremiumPageBlobAccessTierType = PremiumPageBlobAccessTierNone
|
||||
|
||||
|
@ -72,6 +74,30 @@ func (b BlobURL) ToPageBlobURL() PageBlobURL {
|
|||
return NewPageBlobURL(b.URL(), b.blobClient.Pipeline())
|
||||
}
|
||||
|
||||
func SerializeBlobTagsHeader(blobTagsMap BlobTagsMap) *string {
|
||||
if blobTagsMap == nil {
|
||||
return nil
|
||||
}
|
||||
tags := make([]string, 0)
|
||||
for key, val := range blobTagsMap {
|
||||
tags = append(tags, url.QueryEscape(key)+"="+url.QueryEscape(val))
|
||||
}
|
||||
//tags = tags[:len(tags)-1]
|
||||
blobTagsString := strings.Join(tags, "&")
|
||||
return &blobTagsString
|
||||
}
|
||||
|
||||
func SerializeBlobTags(blobTagsMap BlobTagsMap) BlobTags {
|
||||
if blobTagsMap == nil {
|
||||
return BlobTags{}
|
||||
}
|
||||
blobTagSet := make([]BlobTag, 0, len(blobTagsMap))
|
||||
for key, val := range blobTagsMap {
|
||||
blobTagSet = append(blobTagSet, BlobTag{Key: key, Value: val})
|
||||
}
|
||||
return BlobTags{BlobTagSet: blobTagSet}
|
||||
}
|
||||
|
||||
// DownloadBlob reads a range of bytes from a blob. The response also includes the blob's properties and metadata.
|
||||
// Passing azblob.CountToEnd (0) for count will download the blob from the offset to the end.
|
||||
// Note: Snapshot/VersionId are optional parameters which are part of request URL query params.
|
||||
|
@ -89,7 +115,7 @@ func (b BlobURL) Download(ctx context.Context, offset int64, count int64, ac Blo
|
|||
ac.LeaseAccessConditions.pointers(), xRangeGetContentMD5, nil,
|
||||
nil, nil, EncryptionAlgorithmNone, // CPK
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -112,10 +138,25 @@ func (b BlobURL) Delete(ctx context.Context, deleteOptions DeleteSnapshotsOption
|
|||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
|
||||
return b.blobClient.Delete(ctx, nil, nil, nil, ac.LeaseAccessConditions.pointers(), deleteOptions,
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
// The Set Tags 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 (b BlobURL) SetTags(ctx context.Context, timeout *int32, versionID *string, transactionalContentMD5 []byte, transactionalContentCrc64 []byte, requestID *string, ifTags *string, blobTagsMap BlobTagsMap) (*BlobSetTagsResponse, error) {
|
||||
tags := SerializeBlobTags(blobTagsMap)
|
||||
return b.blobClient.SetTags(ctx, timeout, versionID, transactionalContentMD5, transactionalContentCrc64, requestID, ifTags, &tags)
|
||||
}
|
||||
|
||||
// The Get Tags 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 (b BlobURL) GetTags(ctx context.Context, timeout *int32, requestID *string, snapshot *string, versionID *string, ifTags *string) (*BlobTags, error) {
|
||||
return b.blobClient.GetTags(ctx, timeout, requestID, snapshot, versionID, ifTags)
|
||||
}
|
||||
|
||||
// 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 (b BlobURL) Undelete(ctx context.Context) (*BlobUndeleteResponse, error) {
|
||||
|
@ -147,7 +188,7 @@ func (b BlobURL) GetProperties(ctx context.Context, ac BlobAccessConditions) (*B
|
|||
nil, ac.LeaseAccessConditions.pointers(),
|
||||
nil, nil, EncryptionAlgorithmNone, // CPK
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
|
@ -158,7 +199,7 @@ func (b BlobURL) SetHTTPHeaders(ctx context.Context, h BlobHTTPHeaders, ac BlobA
|
|||
return b.blobClient.SetHTTPHeaders(ctx, nil,
|
||||
&h.CacheControl, &h.ContentType, h.ContentMD5, &h.ContentEncoding, &h.ContentLanguage,
|
||||
ac.LeaseAccessConditions.pointers(), ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
&h.ContentDisposition, nil)
|
||||
}
|
||||
|
||||
|
@ -170,7 +211,7 @@ func (b BlobURL) SetMetadata(ctx context.Context, metadata Metadata, ac BlobAcce
|
|||
nil, nil, EncryptionAlgorithmNone, // CPK-V
|
||||
nil, // CPK-N
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
|
@ -185,7 +226,7 @@ func (b BlobURL) CreateSnapshot(ctx context.Context, metadata Metadata, ac BlobA
|
|||
nil, nil, EncryptionAlgorithmNone, // CPK-V
|
||||
nil, // CPK-N
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
ac.LeaseAccessConditions.pointers(), nil)
|
||||
}
|
||||
|
||||
|
@ -196,7 +237,7 @@ func (b BlobURL) AcquireLease(ctx context.Context, proposedID string, duration i
|
|||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.pointers()
|
||||
return b.blobClient.AcquireLease(ctx, nil, &duration, &proposedID,
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
|
@ -206,7 +247,7 @@ func (b BlobURL) RenewLease(ctx context.Context, leaseID string, ac ModifiedAcce
|
|||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.pointers()
|
||||
return b.blobClient.RenewLease(ctx, leaseID, nil,
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
|
@ -216,7 +257,7 @@ func (b BlobURL) ReleaseLease(ctx context.Context, leaseID string, ac ModifiedAc
|
|||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.pointers()
|
||||
return b.blobClient.ReleaseLease(ctx, leaseID, nil,
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
|
@ -227,7 +268,7 @@ func (b BlobURL) BreakLease(ctx context.Context, breakPeriodInSeconds int32, ac
|
|||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.pointers()
|
||||
return b.blobClient.BreakLease(ctx, nil, leasePeriodPointer(breakPeriodInSeconds),
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
|
@ -237,7 +278,7 @@ func (b BlobURL) ChangeLease(ctx context.Context, leaseID string, proposedID str
|
|||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.pointers()
|
||||
return b.blobClient.ChangeLease(ctx, leaseID, proposedID,
|
||||
nil, ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
|
@ -253,21 +294,21 @@ func leasePeriodPointer(period int32) (p *int32) {
|
|||
|
||||
// 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 (b BlobURL) StartCopyFromURL(ctx context.Context, source url.URL, metadata Metadata, srcac ModifiedAccessConditions, dstac BlobAccessConditions, tier AccessTierType) (*BlobStartCopyFromURLResponse, error) {
|
||||
func (b BlobURL) StartCopyFromURL(ctx context.Context, source url.URL, metadata Metadata, srcac ModifiedAccessConditions, dstac BlobAccessConditions, tier AccessTierType, blobTagsMap BlobTagsMap) (*BlobStartCopyFromURLResponse, error) {
|
||||
srcIfModifiedSince, srcIfUnmodifiedSince, srcIfMatchETag, srcIfNoneMatchETag := srcac.pointers()
|
||||
dstIfModifiedSince, dstIfUnmodifiedSince, dstIfMatchETag, dstIfNoneMatchETag := dstac.ModifiedAccessConditions.pointers()
|
||||
dstLeaseID := dstac.LeaseAccessConditions.pointers()
|
||||
|
||||
blobTagsString := SerializeBlobTagsHeader(blobTagsMap)
|
||||
return b.blobClient.StartCopyFromURL(ctx, source.String(), nil, metadata,
|
||||
tier, RehydratePriorityNone, srcIfModifiedSince, srcIfUnmodifiedSince,
|
||||
srcIfMatchETag, srcIfNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // source ifTags
|
||||
dstIfModifiedSince, dstIfUnmodifiedSince,
|
||||
dstIfMatchETag, dstIfNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
dstLeaseID,
|
||||
nil,
|
||||
nil, // Blob tags
|
||||
blobTagsString, // Blob tags
|
||||
nil)
|
||||
}
|
||||
|
||||
|
|
|
@ -64,9 +64,10 @@ func (bb BlockBlobURL) GetAccountInfo(ctx context.Context) (*BlobGetAccountInfoR
|
|||
// 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 (bb BlockBlobURL) Upload(ctx context.Context, body io.ReadSeeker, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, tier AccessTierType) (*BlockBlobUploadResponse, error) {
|
||||
func (bb BlockBlobURL) Upload(ctx context.Context, body io.ReadSeeker, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, tier AccessTierType, blobTagsMap BlobTagsMap) (*BlockBlobUploadResponse, error) {
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
|
||||
count, err := validateSeekableStreamAt0AndGetCount(body)
|
||||
blobTagsString := SerializeBlobTagsHeader(blobTagsMap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -76,9 +77,9 @@ func (bb BlockBlobURL) Upload(ctx context.Context, body io.ReadSeeker, h BlobHTT
|
|||
nil, nil, EncryptionAlgorithmNone, // CPK-V
|
||||
nil, // CPK-N
|
||||
tier, ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil,
|
||||
nil, // Blob tags
|
||||
blobTagsString, // Blob tags
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -113,9 +114,9 @@ func (bb BlockBlobURL) StageBlockFromURL(ctx context.Context, base64BlockID stri
|
|||
// 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 (bb BlockBlobURL) CommitBlockList(ctx context.Context, base64BlockIDs []string, h BlobHTTPHeaders,
|
||||
metadata Metadata, ac BlobAccessConditions, tier AccessTierType) (*BlockBlobCommitBlockListResponse, error) {
|
||||
func (bb BlockBlobURL) CommitBlockList(ctx context.Context, base64BlockIDs []string, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, tier AccessTierType, blobTagsMap BlobTagsMap) (*BlockBlobCommitBlockListResponse, error) {
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
|
||||
blobTagsString := SerializeBlobTagsHeader(blobTagsMap)
|
||||
return bb.bbClient.CommitBlockList(ctx, BlockLookupList{Latest: base64BlockIDs}, nil,
|
||||
&h.CacheControl, &h.ContentType, &h.ContentEncoding, &h.ContentLanguage, h.ContentMD5, nil, nil,
|
||||
metadata, ac.LeaseAccessConditions.pointers(), &h.ContentDisposition,
|
||||
|
@ -123,9 +124,9 @@ func (bb BlockBlobURL) CommitBlockList(ctx context.Context, base64BlockIDs []str
|
|||
nil, // CPK-N
|
||||
tier,
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil,
|
||||
nil, // Blob tags
|
||||
blobTagsString, // Blob tags
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -133,27 +134,26 @@ func (bb BlockBlobURL) CommitBlockList(ctx context.Context, base64BlockIDs []str
|
|||
// For more information, see https://docs.microsoft.com/rest/api/storageservices/get-block-list.
|
||||
func (bb BlockBlobURL) GetBlockList(ctx context.Context, listType BlockListType, ac LeaseAccessConditions) (*BlockList, error) {
|
||||
return bb.bbClient.GetBlockList(ctx, listType, nil, nil, ac.pointers(),
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
// 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 (bb BlockBlobURL) CopyFromURL(ctx context.Context, source url.URL, metadata Metadata,
|
||||
srcac ModifiedAccessConditions, dstac BlobAccessConditions, srcContentMD5 []byte, tier AccessTierType) (*BlobCopyFromURLResponse, error) {
|
||||
func (bb BlockBlobURL) CopyFromURL(ctx context.Context, source url.URL, metadata Metadata, srcac ModifiedAccessConditions, dstac BlobAccessConditions, srcContentMD5 []byte, tier AccessTierType, blobTagsMap BlobTagsMap) (*BlobCopyFromURLResponse, error) {
|
||||
|
||||
srcIfModifiedSince, srcIfUnmodifiedSince, srcIfMatchETag, srcIfNoneMatchETag := srcac.pointers()
|
||||
dstIfModifiedSince, dstIfUnmodifiedSince, dstIfMatchETag, dstIfNoneMatchETag := dstac.ModifiedAccessConditions.pointers()
|
||||
dstLeaseID := dstac.LeaseAccessConditions.pointers()
|
||||
|
||||
blobTagsString := SerializeBlobTagsHeader(blobTagsMap)
|
||||
return bb.blobClient.CopyFromURL(ctx, source.String(), nil, metadata, tier,
|
||||
srcIfModifiedSince, srcIfUnmodifiedSince,
|
||||
srcIfMatchETag, srcIfNoneMatchETag,
|
||||
dstIfModifiedSince, dstIfUnmodifiedSince,
|
||||
dstIfMatchETag, dstIfNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
dstLeaseID, nil, srcContentMD5,
|
||||
nil, // Blob tags
|
||||
nil, // seal Blob
|
||||
blobTagsString, // Blob tags
|
||||
nil, // seal Blob
|
||||
)
|
||||
}
|
||||
|
|
|
@ -58,8 +58,9 @@ func (pb PageBlobURL) GetAccountInfo(ctx context.Context) (*BlobGetAccountInfoRe
|
|||
|
||||
// Create creates a page blob of the specified length. Call PutPage to upload data data to a page blob.
|
||||
// For more information, see https://docs.microsoft.com/rest/api/storageservices/put-blob.
|
||||
func (pb PageBlobURL) Create(ctx context.Context, size int64, sequenceNumber int64, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, tier PremiumPageBlobAccessTierType) (*PageBlobCreateResponse, error) {
|
||||
func (pb PageBlobURL) Create(ctx context.Context, size int64, sequenceNumber int64, h BlobHTTPHeaders, metadata Metadata, ac BlobAccessConditions, tier PremiumPageBlobAccessTierType, blobTagsMap BlobTagsMap) (*PageBlobCreateResponse, error) {
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()
|
||||
blobTagsString := SerializeBlobTagsHeader(blobTagsMap)
|
||||
return pb.pbClient.Create(ctx, 0, size, nil, tier,
|
||||
&h.ContentType, &h.ContentEncoding, &h.ContentLanguage, h.ContentMD5, &h.CacheControl,
|
||||
metadata, ac.LeaseAccessConditions.pointers(), &h.ContentDisposition,
|
||||
|
@ -68,7 +69,7 @@ func (pb PageBlobURL) Create(ctx context.Context, size int64, sequenceNumber int
|
|||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
&sequenceNumber, nil,
|
||||
nil, // Blob tags
|
||||
blobTagsString, // Blob tags
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -90,7 +91,7 @@ func (pb PageBlobURL) UploadPages(ctx context.Context, offset int64, body io.Rea
|
|||
nil, // CPK-N
|
||||
ifSequenceNumberLessThanOrEqual, ifSequenceNumberLessThan, ifSequenceNumberEqual,
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ func (pb PageBlobURL) UploadPagesFromURL(ctx context.Context, sourceURL url.URL,
|
|||
destinationAccessConditions.LeaseAccessConditions.pointers(),
|
||||
ifSequenceNumberLessThanOrEqual, ifSequenceNumberLessThan, ifSequenceNumberEqual,
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
sourceIfModifiedSince, sourceIfUnmodifiedSince, sourceIfMatchETag, sourceIfNoneMatchETag, nil)
|
||||
}
|
||||
|
||||
|
@ -136,7 +137,7 @@ func (pb PageBlobURL) GetPageRanges(ctx context.Context, offset int64, count int
|
|||
httpRange{offset: offset, count: count}.pointers(),
|
||||
ac.LeaseAccessConditions.pointers(),
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
|
@ -149,7 +150,7 @@ func (pb PageBlobURL) GetPageRangesDiff(ctx context.Context, offset int64, count
|
|||
httpRange{offset: offset, count: count}.pointers(),
|
||||
ac.LeaseAccessConditions.pointers(),
|
||||
ifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,
|
||||
nil, // Blob tags
|
||||
nil, // Blob ifTags
|
||||
nil)
|
||||
}
|
||||
|
||||
|
|
|
@ -163,3 +163,10 @@ func (bsu ServiceURL) SetProperties(ctx context.Context, properties StorageServi
|
|||
func (bsu ServiceURL) GetStatistics(ctx context.Context) (*StorageServiceStats, error) {
|
||||
return bsu.client.GetStatistics(ctx, nil, nil)
|
||||
}
|
||||
|
||||
// FindBlobsByTags operation finds all blobs in the storage account whose tags match a given search expression.
|
||||
// Filter blobs searches across all containers within a storage account but can be scoped within the expression to a single container.
|
||||
// https://docs.microsoft.com/en-us/rest/api/storageservices/find-blobs-by-tags
|
||||
func (bsu ServiceURL) FindBlobsByTags(ctx context.Context, timeout *int32, requestID *string, where *string, marker Marker, maxResults *int32) (*FilterBlobSegment, error) {
|
||||
return bsu.client.FilterBlobs(ctx, timeout, requestID, where, marker.Val, maxResults)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,579 @@
|
|||
package azblob
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
chk "gopkg.in/check.v1"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (s *aztestsSuite) TestSetBlobTags(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
containerURL, _ := createNewContainer(c, bsu)
|
||||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
blobTagsMap := BlobTagsMap{
|
||||
"azure": "blob",
|
||||
"blob": "sdk",
|
||||
"sdk": "go",
|
||||
}
|
||||
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
|
||||
blobSetTagsResponse, err := blobURL.SetTags(ctx, nil, nil, nil, nil, nil, nil, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobSetTagsResponse.StatusCode(), chk.Equals, 204)
|
||||
|
||||
blobGetTagsResponse, err := blobURL.GetTags(ctx, nil, nil, nil, nil, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobGetTagsResponse.StatusCode(), chk.Equals, 200)
|
||||
c.Assert(blobGetTagsResponse.BlobTagSet, chk.HasLen, 3)
|
||||
for _, blobTag := range blobGetTagsResponse.BlobTagSet {
|
||||
c.Assert(blobTagsMap[blobTag.Key], chk.Equals, blobTag.Value)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestSetBlobTagsWithVID(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
containerURL, _ := createNewContainer(c, bsu)
|
||||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
blobTagsMap := BlobTagsMap{
|
||||
"Go": "CPlusPlus",
|
||||
"Python": "CSharp",
|
||||
"Javascript": "Android",
|
||||
}
|
||||
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
|
||||
versionId1 := blockBlobUploadResp.VersionID()
|
||||
|
||||
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
|
||||
versionId2 := blockBlobUploadResp.VersionID()
|
||||
|
||||
blobSetTagsResponse, err := blobURL.SetTags(ctx, nil, &versionId1, nil, nil, nil, nil, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobSetTagsResponse.StatusCode(), chk.Equals, 204)
|
||||
|
||||
blobGetTagsResponse, err := blobURL.GetTags(ctx, nil, nil, nil, &versionId1, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobGetTagsResponse.StatusCode(), chk.Equals, 200)
|
||||
c.Assert(blobGetTagsResponse.BlobTagSet, chk.HasLen, 3)
|
||||
for _, blobTag := range blobGetTagsResponse.BlobTagSet {
|
||||
c.Assert(blobTagsMap[blobTag.Key], chk.Equals, blobTag.Value)
|
||||
}
|
||||
|
||||
blobGetTagsResponse, err = blobURL.GetTags(ctx, nil, nil, nil, &versionId2, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobGetTagsResponse.StatusCode(), chk.Equals, 200)
|
||||
c.Assert(blobGetTagsResponse.BlobTagSet, chk.IsNil)
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestSetBlobTagsWithVID2(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
containerURL, _ := createNewContainer(c, bsu)
|
||||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
|
||||
versionId1 := blockBlobUploadResp.VersionID()
|
||||
|
||||
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
|
||||
versionId2 := blockBlobUploadResp.VersionID()
|
||||
|
||||
blobTags1 := BlobTagsMap{
|
||||
"Go": "CPlusPlus",
|
||||
"Python": "CSharp",
|
||||
"Javascript": "Android",
|
||||
}
|
||||
|
||||
blobSetTagsResponse, err := blobURL.SetTags(ctx, nil, &versionId1, nil, nil, nil, nil, blobTags1)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobSetTagsResponse.StatusCode(), chk.Equals, 204)
|
||||
|
||||
blobGetTagsResponse, err := blobURL.GetTags(ctx, nil, nil, nil, &versionId1, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobGetTagsResponse.StatusCode(), chk.Equals, 200)
|
||||
c.Assert(blobGetTagsResponse.BlobTagSet, chk.HasLen, 3)
|
||||
for _, blobTag := range blobGetTagsResponse.BlobTagSet {
|
||||
c.Assert(blobTags1[blobTag.Key], chk.Equals, blobTag.Value)
|
||||
}
|
||||
|
||||
blobTags2 := BlobTagsMap{
|
||||
"a123": "321a",
|
||||
"b234": "432b",
|
||||
}
|
||||
blobSetTagsResponse, err = blobURL.SetTags(ctx, nil, &versionId2, nil, nil, nil, nil, blobTags2)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobSetTagsResponse.StatusCode(), chk.Equals, 204)
|
||||
|
||||
blobGetTagsResponse, err = blobURL.GetTags(ctx, nil, nil, nil, &versionId2, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobGetTagsResponse.StatusCode(), chk.Equals, 200)
|
||||
c.Assert(blobGetTagsResponse.BlobTagSet, chk.NotNil)
|
||||
for _, blobTag := range blobGetTagsResponse.BlobTagSet {
|
||||
c.Assert(blobTags2[blobTag.Key], chk.Equals, blobTag.Value)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestUploadBlockBlobWithSpecialCharactersInTags(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
containerURL, _ := createNewContainer(c, bsu)
|
||||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
blobTagsMap := BlobTagsMap{
|
||||
"+-./:=_ ": "firsttag",
|
||||
"tag2": "+-./:=_",
|
||||
"+-./:=_1": "+-./:=_",
|
||||
}
|
||||
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
|
||||
|
||||
blobGetTagsResponse, err := blobURL.GetTags(ctx, nil, nil, nil, nil, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobGetTagsResponse.StatusCode(), chk.Equals, 200)
|
||||
c.Assert(blobGetTagsResponse.BlobTagSet, chk.HasLen, 3)
|
||||
for _, blobTag := range blobGetTagsResponse.BlobTagSet {
|
||||
c.Assert(blobTagsMap[blobTag.Key], chk.Equals, blobTag.Value)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestStageBlockWithTags(c *chk.C) {
|
||||
blockIDIntToBase64 := func(blockID int) string {
|
||||
binaryBlockID := (&[4]byte{})[:]
|
||||
binary.LittleEndian.PutUint32(binaryBlockID, uint32(blockID))
|
||||
return base64.StdEncoding.EncodeToString(binaryBlockID)
|
||||
}
|
||||
bsu := getBSU()
|
||||
containerURL, _ := createNewContainer(c, bsu)
|
||||
defer delContainer(c, containerURL)
|
||||
|
||||
blobURL := containerURL.NewBlockBlobURL(generateBlobName())
|
||||
|
||||
data := []string{"Azure ", "Storage ", "Block ", "Blob."}
|
||||
base64BlockIDs := make([]string, len(data))
|
||||
|
||||
for index, d := range data {
|
||||
base64BlockIDs[index] = blockIDIntToBase64(index)
|
||||
resp, err := blobURL.StageBlock(ctx, base64BlockIDs[index], strings.NewReader(d), LeaseAccessConditions{}, nil)
|
||||
if err != nil {
|
||||
c.Fail()
|
||||
}
|
||||
c.Assert(resp.Response().StatusCode, chk.Equals, 201)
|
||||
c.Assert(resp.Version(), chk.Not(chk.Equals), "")
|
||||
}
|
||||
|
||||
blobTagsMap := BlobTagsMap{
|
||||
"azure": "blob",
|
||||
"blob": "sdk",
|
||||
"sdk": "go",
|
||||
}
|
||||
commitResp, err := blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(commitResp.VersionID(), chk.NotNil)
|
||||
versionId := commitResp.VersionID()
|
||||
|
||||
contentResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
|
||||
c.Assert(err, chk.IsNil)
|
||||
contentData, err := ioutil.ReadAll(contentResp.Body(RetryReaderOptions{}))
|
||||
c.Assert(contentData, chk.DeepEquals, []uint8(strings.Join(data, "")))
|
||||
|
||||
blobGetTagsResp, err := blobURL.GetTags(ctx, nil, nil, nil, &versionId, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobGetTagsResp, chk.NotNil)
|
||||
c.Assert(blobGetTagsResp.BlobTagSet, chk.HasLen, 3)
|
||||
for _, blobTag := range blobGetTagsResp.BlobTagSet {
|
||||
c.Assert(blobTagsMap[blobTag.Key], chk.Equals, blobTag.Value)
|
||||
}
|
||||
|
||||
blobGetTagsResp, err = blobURL.GetTags(ctx, nil, nil, nil, nil, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobGetTagsResp, chk.NotNil)
|
||||
c.Assert(blobGetTagsResp.BlobTagSet, chk.HasLen, 3)
|
||||
for _, blobTag := range blobGetTagsResp.BlobTagSet {
|
||||
c.Assert(blobTagsMap[blobTag.Key], chk.Equals, blobTag.Value)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestStageBlockFromURLWithTags(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
credential, err := getGenericCredential("")
|
||||
if err != nil {
|
||||
c.Fatal("Invalid credential")
|
||||
}
|
||||
container, _ := createNewContainer(c, bsu)
|
||||
defer delContainer(c, container)
|
||||
|
||||
testSize := 8 * 1024 * 1024 // 8MB
|
||||
r, sourceData := getRandomDataAndReader(testSize)
|
||||
ctx := ctx // Use default Background context
|
||||
srcBlob := container.NewBlockBlobURL("sourceBlob")
|
||||
destBlob := container.NewBlockBlobURL("destBlob")
|
||||
|
||||
blobTagsMap := BlobTagsMap{
|
||||
"Go": "CPlusPlus",
|
||||
"Python": "CSharp",
|
||||
"Javascript": "Android",
|
||||
}
|
||||
|
||||
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
|
||||
|
||||
// Get source blob URL with SAS for StageFromURL.
|
||||
srcBlobParts := NewBlobURLParts(srcBlob.URL())
|
||||
|
||||
srcBlobParts.SAS, err = BlobSASSignatureValues{
|
||||
Protocol: SASProtocolHTTPS, // Users MUST use HTTPS (not HTTP)
|
||||
ExpiryTime: time.Now().UTC().Add(48 * time.Hour), // 48-hours before expiration
|
||||
ContainerName: srcBlobParts.ContainerName,
|
||||
BlobName: srcBlobParts.BlobName,
|
||||
Permissions: BlobSASPermissions{Read: true}.String(),
|
||||
}.NewSASQueryParameters(credential)
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
srcBlobURLWithSAS := srcBlobParts.URL()
|
||||
|
||||
blockID1, blockID2 := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%6d", 0))), base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%6d", 1)))
|
||||
stageResp1, err := destBlob.StageBlockFromURL(ctx, blockID1, srcBlobURLWithSAS, 0, 4*1024*1024, LeaseAccessConditions{}, ModifiedAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(stageResp1.Response().StatusCode, chk.Equals, 201)
|
||||
c.Assert(stageResp1.ContentMD5(), chk.Not(chk.Equals), "")
|
||||
c.Assert(stageResp1.RequestID(), chk.Not(chk.Equals), "")
|
||||
c.Assert(stageResp1.Version(), chk.Not(chk.Equals), "")
|
||||
c.Assert(stageResp1.Date().IsZero(), chk.Equals, false)
|
||||
|
||||
stageResp2, err := destBlob.StageBlockFromURL(ctx, blockID2, srcBlobURLWithSAS, 4*1024*1024, CountToEnd, LeaseAccessConditions{}, ModifiedAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(stageResp2.Response().StatusCode, chk.Equals, 201)
|
||||
c.Assert(stageResp2.ContentMD5(), chk.Not(chk.Equals), "")
|
||||
c.Assert(stageResp2.RequestID(), chk.Not(chk.Equals), "")
|
||||
c.Assert(stageResp2.Version(), chk.Not(chk.Equals), "")
|
||||
c.Assert(stageResp2.Date().IsZero(), chk.Equals, false)
|
||||
|
||||
blockList, err := destBlob.GetBlockList(ctx, BlockListAll, LeaseAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blockList.Response().StatusCode, chk.Equals, 200)
|
||||
c.Assert(blockList.CommittedBlocks, chk.HasLen, 0)
|
||||
c.Assert(blockList.UncommittedBlocks, chk.HasLen, 2)
|
||||
|
||||
listResp, err := destBlob.CommitBlockList(ctx, []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(listResp.Response().StatusCode, chk.Equals, 201)
|
||||
//versionId := listResp.VersionID()
|
||||
|
||||
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
|
||||
c.Assert(err, chk.IsNil)
|
||||
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(destData, chk.DeepEquals, sourceData)
|
||||
|
||||
blobGetTagsResp, err := destBlob.GetTags(ctx, nil, nil, nil, nil, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blobGetTagsResp.BlobTagSet, chk.HasLen, 3)
|
||||
for _, blobTag := range blobGetTagsResp.BlobTagSet {
|
||||
c.Assert(blobTagsMap[blobTag.Key], chk.Equals, blobTag.Value)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestCopyBlockBlobFromURLWithTags(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
credential, err := getGenericCredential("")
|
||||
if err != nil {
|
||||
c.Fatal("Invalid credential")
|
||||
}
|
||||
container, _ := createNewContainer(c, bsu)
|
||||
defer delContainer(c, container)
|
||||
|
||||
testSize := 1 * 1024 * 1024 // 1MB
|
||||
r, sourceData := getRandomDataAndReader(testSize)
|
||||
sourceDataMD5Value := md5.Sum(sourceData)
|
||||
srcBlob := container.NewBlockBlobURL("srcBlob")
|
||||
destBlob := container.NewBlockBlobURL("destBlob")
|
||||
|
||||
blobTagsMap := BlobTagsMap{
|
||||
"Go": "CPlusPlus",
|
||||
"Python": "CSharp",
|
||||
"Javascript": "Android",
|
||||
}
|
||||
|
||||
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
|
||||
|
||||
// Get source blob URL with SAS for StageFromURL.
|
||||
srcBlobParts := NewBlobURLParts(srcBlob.URL())
|
||||
|
||||
srcBlobParts.SAS, err = BlobSASSignatureValues{
|
||||
Protocol: SASProtocolHTTPS, // Users MUST use HTTPS (not HTTP)
|
||||
ExpiryTime: time.Now().UTC().Add(48 * time.Hour), // 48-hours before expiration
|
||||
ContainerName: srcBlobParts.ContainerName,
|
||||
BlobName: srcBlobParts.BlobName,
|
||||
Permissions: BlobSASPermissions{Read: true}.String(),
|
||||
}.NewSASQueryParameters(credential)
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
srcBlobURLWithSAS := srcBlobParts.URL()
|
||||
|
||||
resp, err := destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{"foo": "bar"}, ModifiedAccessConditions{}, BlobAccessConditions{}, sourceDataMD5Value[:], DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.Response().StatusCode, chk.Equals, 202)
|
||||
c.Assert(resp.ETag(), chk.Not(chk.Equals), "")
|
||||
c.Assert(resp.RequestID(), chk.Not(chk.Equals), "")
|
||||
c.Assert(resp.Version(), chk.Not(chk.Equals), "")
|
||||
c.Assert(resp.Date().IsZero(), chk.Equals, false)
|
||||
c.Assert(resp.CopyID(), chk.Not(chk.Equals), "")
|
||||
c.Assert(resp.ContentMD5(), chk.DeepEquals, sourceDataMD5Value[:])
|
||||
c.Assert(string(resp.CopyStatus()), chk.DeepEquals, "success")
|
||||
|
||||
downloadResp, err := destBlob.BlobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
|
||||
c.Assert(err, chk.IsNil)
|
||||
destData, err := ioutil.ReadAll(downloadResp.Body(RetryReaderOptions{}))
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(destData, chk.DeepEquals, sourceData)
|
||||
|
||||
c.Assert(len(downloadResp.NewMetadata()), chk.Equals, 1)
|
||||
|
||||
_, badMD5 := getRandomDataAndReader(16)
|
||||
_, err = destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, badMD5, DefaultAccessTier, blobTagsMap)
|
||||
c.Assert(err, chk.NotNil)
|
||||
|
||||
resp, err = destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, nil, DefaultAccessTier, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.Response().StatusCode, chk.Equals, 202)
|
||||
c.Assert(resp.XMsContentCrc64(), chk.Not(chk.Equals), "")
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestGetPropertiesReturnsTagsCount(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
containerURL, _ := createNewContainer(c, bsu)
|
||||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
blobTagsMap := BlobTagsMap{
|
||||
"azure": "blob",
|
||||
"blob": "sdk",
|
||||
"sdk": "go",
|
||||
}
|
||||
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blockBlobUploadResp.StatusCode(), chk.Equals, 201)
|
||||
|
||||
getPropertiesResponse, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(getPropertiesResponse.TagCount(), chk.Equals, int64(3))
|
||||
|
||||
downloadResp, err := blobURL.Download(ctx, 0, CountToEnd, BlobAccessConditions{}, false)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(downloadResp, chk.NotNil)
|
||||
c.Assert(downloadResp.r.rawResponse.Header.Get("x-ms-tag-count"), chk.Equals, "3")
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestSetBlobTagForSnapshot(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
containerURL, _ := createNewContainer(c, bsu)
|
||||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := createNewBlockBlob(c, containerURL)
|
||||
blobTagsMap := BlobTagsMap{
|
||||
"Microsoft Azure": "Azure Storage",
|
||||
"Storage+SDK": "SDK/GO",
|
||||
"GO ": ".Net",
|
||||
}
|
||||
_, err := blobURL.SetTags(ctx, nil, nil, nil, nil, nil, nil, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
snapshotURL := blobURL.WithSnapshot(resp.Snapshot())
|
||||
resp2, err := snapshotURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp2.TagCount(), chk.Equals, int64(3))
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestCreatePageBlobWithTags(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
container, _ := createNewContainer(c, bsu)
|
||||
defer delContainer(c, container)
|
||||
|
||||
blobTagsMap := BlobTagsMap{
|
||||
"azure": "blob",
|
||||
"blob": "sdk",
|
||||
"sdk": "go",
|
||||
}
|
||||
blob, _ := createNewPageBlob(c, container)
|
||||
putResp, err := blob.UploadPages(ctx, 0, getReaderToRandomBytes(1024), PageBlobAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(putResp.Response().StatusCode, chk.Equals, 201)
|
||||
c.Assert(putResp.LastModified().IsZero(), chk.Equals, false)
|
||||
c.Assert(putResp.ETag(), chk.Not(chk.Equals), ETagNone)
|
||||
c.Assert(putResp.Version(), chk.Not(chk.Equals), "")
|
||||
c.Assert(putResp.rawResponse.Header.Get("x-ms-version-id"), chk.NotNil)
|
||||
|
||||
setTagResp, err := blob.SetTags(ctx, nil, nil, nil, nil, nil, nil, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(setTagResp.StatusCode(), chk.Equals, 204)
|
||||
|
||||
gpResp, err := blob.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(gpResp, chk.NotNil)
|
||||
c.Assert(gpResp.rawResponse.Header.Get("x-ms-tag-count"), chk.Equals, "3")
|
||||
|
||||
modifiedBlobTags := BlobTagsMap{
|
||||
"a0z1u2r3e4": "b0l1o2b3",
|
||||
"b0l1o2b3": "s0d1k2",
|
||||
}
|
||||
|
||||
setTagResp, err = blob.SetTags(ctx, nil, nil, nil, nil, nil, nil, modifiedBlobTags)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(setTagResp.StatusCode(), chk.Equals, 204)
|
||||
|
||||
gpResp, err = blob.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(gpResp, chk.NotNil)
|
||||
c.Assert(gpResp.rawResponse.Header.Get("x-ms-tag-count"), chk.Equals, "2")
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestSetTagOnPageBlob(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
container, _ := createNewContainer(c, bsu)
|
||||
defer delContainer(c, container)
|
||||
|
||||
blob, _ := getPageBlobURL(c, container)
|
||||
blobTagsMap := BlobTagsMap{
|
||||
"azure": "blob",
|
||||
"blob": "sdk",
|
||||
"sdk": "go",
|
||||
}
|
||||
resp, err := blob.Create(ctx, PageBlobPageBytes*10, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.StatusCode(), chk.Equals, 201)
|
||||
|
||||
gpResp, err := blob.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(gpResp, chk.NotNil)
|
||||
c.Assert(gpResp.rawResponse.Header.Get("x-ms-tag-count"), chk.Equals, "3")
|
||||
|
||||
modifiedBlobTags := BlobTagsMap{
|
||||
"a0z1u2r3e4": "b0l1o2b3",
|
||||
"b0l1o2b3": "s0d1k2",
|
||||
}
|
||||
|
||||
setTagResp, err := blob.SetTags(ctx, nil, nil, nil, nil, nil, nil, modifiedBlobTags)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(setTagResp.StatusCode(), chk.Equals, 204)
|
||||
|
||||
gpResp, err = blob.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(gpResp, chk.NotNil)
|
||||
c.Assert(gpResp.rawResponse.Header.Get("x-ms-tag-count"), chk.Equals, "2")
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestCreateAppendBlobWithTags(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
containerURL, _ := createNewContainer(c, bsu)
|
||||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := createNewAppendBlob(c, containerURL)
|
||||
|
||||
blobProp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
createResp, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: blobProp.ETag()}}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(createResp.VersionID(), chk.NotNil)
|
||||
blobProp, _ = blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(createResp.VersionID(), chk.Equals, blobProp.VersionID())
|
||||
c.Assert(createResp.LastModified(), chk.DeepEquals, blobProp.LastModified())
|
||||
c.Assert(createResp.ETag(), chk.Equals, blobProp.ETag())
|
||||
c.Assert(blobProp.IsCurrentVersion(), chk.Equals, "true")
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestListBlobReturnsTags(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
containerURL, _ := createNewContainer(c, bsu)
|
||||
defer deleteContainer(c, containerURL)
|
||||
blobURL, blobName := createNewBlockBlob(c, containerURL)
|
||||
blobTagsMap := BlobTagsMap{
|
||||
"+-./:=_ ": "firsttag",
|
||||
"tag2": "+-./:=_",
|
||||
"+-./:=_1": "+-./:=_",
|
||||
}
|
||||
resp, err := blobURL.SetTags(ctx, nil, nil, nil, nil, nil, nil, blobTagsMap)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.StatusCode(), chk.Equals, 204)
|
||||
|
||||
listBlobResp, err := containerURL.ListBlobsFlatSegment(ctx, Marker{}, ListBlobsSegmentOptions{Details: BlobListingDetails{Tags: true}})
|
||||
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(listBlobResp.Segment.BlobItems[0].Name, chk.Equals, blobName)
|
||||
c.Assert(listBlobResp.Segment.BlobItems[0].BlobTags.BlobTagSet, chk.HasLen, 3)
|
||||
for _, blobTag := range listBlobResp.Segment.BlobItems[0].BlobTags.BlobTagSet {
|
||||
c.Assert(blobTagsMap[blobTag.Key], chk.Equals, blobTag.Value)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestFindBlobsByTags(c *chk.C) {
|
||||
bsu := getBSU()
|
||||
containerURL1, _ := createNewContainer(c, bsu)
|
||||
defer deleteContainer(c, containerURL1)
|
||||
containerURL2, _ := createNewContainer(c, bsu)
|
||||
defer deleteContainer(c, containerURL2)
|
||||
containerURL3, _ := createNewContainer(c, bsu)
|
||||
defer deleteContainer(c, containerURL3)
|
||||
|
||||
blobTagsMap1 := BlobTagsMap{
|
||||
"tag2": "tagsecond",
|
||||
"tag3": "tagthird",
|
||||
}
|
||||
blobTagsMap2 := BlobTagsMap{
|
||||
"tag1": "firsttag",
|
||||
"tag2": "secondtag",
|
||||
"tag3": "thirdtag",
|
||||
}
|
||||
blobURL11, _ := getBlockBlobURL(c, containerURL1)
|
||||
_, err := blobURL11.Upload(ctx, bytes.NewReader([]byte("random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap1)
|
||||
c.Assert(err, chk.IsNil)
|
||||
blobURL12, _ := getBlockBlobURL(c, containerURL1)
|
||||
_, err = blobURL12.Upload(ctx, bytes.NewReader([]byte("another random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap2)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
blobURL21, _ := getBlockBlobURL(c, containerURL2)
|
||||
_, err = blobURL21.Upload(ctx, bytes.NewReader([]byte("random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
blobURL22, _ := getBlockBlobURL(c, containerURL2)
|
||||
_, err = blobURL22.Upload(ctx, bytes.NewReader([]byte("another random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, blobTagsMap2)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
blobURL31, _ := getBlockBlobURL(c, containerURL3)
|
||||
_, err = blobURL31.Upload(ctx, bytes.NewReader([]byte("random data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
where := "\"tag4\"='fourthtag'"
|
||||
lResp, err := bsu.FindBlobsByTags(ctx, nil, nil, &where, Marker{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(lResp.Blobs, chk.HasLen, 0)
|
||||
|
||||
//where = "\"tag1\"='firsttag'AND\"tag2\"='secondtag'AND\"@container\"='"+ containerName1 + "'"
|
||||
//TODO: Figure out how to do a composite query based on container.
|
||||
where = "\"tag1\"='firsttag'AND\"tag2\"='secondtag'"
|
||||
|
||||
lResp, err = bsu.FindBlobsByTags(ctx, nil, nil, &where, Marker{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
for _, blob := range lResp.Blobs {
|
||||
c.Assert(blob.TagValue, chk.Equals, "firsttag")
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ func (s *aztestsSuite) TestGetBlobPropertiesUsingVID(c *chk.C) {
|
|||
blobURL, _ := createNewAppendBlob(c, containerURL)
|
||||
|
||||
blobProp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
createResp, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: blobProp.ETag()}})
|
||||
createResp, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: blobProp.ETag()}}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(createResp.VersionID(), chk.NotNil)
|
||||
blobProp, _ = blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -58,7 +58,7 @@ func (s *aztestsSuite) TestCreateAndDownloadBlobSpecialCharactersWithVID(c *chk.
|
|||
for i := 0; i < len(data); i++ {
|
||||
blobName := "abc" + string(data[i])
|
||||
blobURL := containerURL.NewBlockBlobURL(blobName)
|
||||
resp, err := blobURL.Upload(ctx, strings.NewReader(string(data[i])), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
resp, err := blobURL.Upload(ctx, strings.NewReader(string(data[i])), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.VersionID(), chk.NotNil)
|
||||
|
||||
|
@ -79,14 +79,12 @@ func (s *aztestsSuite) TestDeleteSpecificBlobVersion(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{},
|
||||
basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blockBlobUploadResp.VersionID(), chk.NotNil)
|
||||
versionID1 := blockBlobUploadResp.VersionID()
|
||||
|
||||
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{},
|
||||
basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blockBlobUploadResp.VersionID(), chk.NotNil)
|
||||
|
||||
|
@ -117,14 +115,12 @@ func (s *aztestsSuite) TestDeleteSpecificBlobVersionWithBlobSAS(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, blobName := getBlockBlobURL(c, containerURL)
|
||||
|
||||
resp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{},
|
||||
basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
resp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
versionId := resp.VersionID()
|
||||
c.Assert(versionId, chk.NotNil)
|
||||
|
||||
resp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{},
|
||||
basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
resp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.VersionID(), chk.NotNil)
|
||||
|
||||
|
@ -158,14 +154,12 @@ func (s *aztestsSuite) TestDownloadSpecificBlobVersion(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{},
|
||||
basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
blockBlobUploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blockBlobUploadResp, chk.NotNil)
|
||||
versionId1 := blockBlobUploadResp.VersionID()
|
||||
|
||||
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{},
|
||||
basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
blockBlobUploadResp, err = blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(blockBlobUploadResp, chk.NotNil)
|
||||
versionId2 := blockBlobUploadResp.VersionID()
|
||||
|
@ -191,8 +185,7 @@ func (s *aztestsSuite) TestCreateBlobSnapshotReturnsVID(c *chk.C) {
|
|||
containerURL, _ := createNewContainer(c, bsu)
|
||||
defer delContainer(c, containerURL)
|
||||
blobURL := containerURL.NewBlockBlobURL(generateBlobName())
|
||||
uploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{},
|
||||
basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
uploadResp, err := blobURL.Upload(ctx, bytes.NewReader([]byte("updated_data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(uploadResp.VersionID(), chk.NotNil)
|
||||
|
||||
|
@ -236,7 +229,7 @@ func (s *aztestsSuite) TestCopyBlobFromURLWithSASReturnsVID(c *chk.C) {
|
|||
srcBlob := container.NewBlockBlobURL(generateBlobName())
|
||||
destBlob := container.NewBlockBlobURL(generateBlobName())
|
||||
|
||||
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
|
||||
c.Assert(uploadSrcResp.Response().Header.Get("x-ms-version-id"), chk.NotNil)
|
||||
|
@ -256,7 +249,7 @@ func (s *aztestsSuite) TestCopyBlobFromURLWithSASReturnsVID(c *chk.C) {
|
|||
|
||||
srcBlobURLWithSAS := srcBlobParts.URL()
|
||||
|
||||
resp, err := destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{"foo": "bar"}, ModifiedAccessConditions{}, BlobAccessConditions{}, sourceDataMD5Value[:], DefaultAccessTier)
|
||||
resp, err := destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{"foo": "bar"}, ModifiedAccessConditions{}, BlobAccessConditions{}, sourceDataMD5Value[:], DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.Response().StatusCode, chk.Equals, 202)
|
||||
c.Assert(resp.Version(), chk.Not(chk.Equals), "")
|
||||
|
@ -272,10 +265,10 @@ func (s *aztestsSuite) TestCopyBlobFromURLWithSASReturnsVID(c *chk.C) {
|
|||
c.Assert(downloadResp.Response().Header.Get("x-ms-version-id"), chk.NotNil)
|
||||
c.Assert(len(downloadResp.NewMetadata()), chk.Equals, 1)
|
||||
_, badMD5 := getRandomDataAndReader(16)
|
||||
_, err = destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, badMD5, DefaultAccessTier)
|
||||
_, err = destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, badMD5, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.NotNil)
|
||||
|
||||
resp, err = destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, nil, DefaultAccessTier)
|
||||
resp, err = destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, nil, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.Response().StatusCode, chk.Equals, 202)
|
||||
c.Assert(resp.XMsContentCrc64(), chk.Not(chk.Equals), "")
|
||||
|
@ -294,7 +287,7 @@ func (s *aztestsSuite) TestCreateBlockBlobReturnsVID(c *chk.C) {
|
|||
blobURL := containerURL.NewBlockBlobURL(generateBlobName())
|
||||
|
||||
// Prepare source blob for copy.
|
||||
uploadResp, err := blobURL.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
uploadResp, err := blobURL.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(uploadResp.Response().StatusCode, chk.Equals, 201)
|
||||
c.Assert(uploadResp.rawResponse.Header.Get("x-ms-version"), chk.Equals, ServiceVersion)
|
||||
|
@ -352,7 +345,7 @@ func (s *aztestsSuite) TestPutBlockListReturnsVID(c *chk.C) {
|
|||
c.Assert(resp.Version(), chk.Not(chk.Equals), "")
|
||||
}
|
||||
|
||||
commitResp, err := blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
commitResp, err := blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(commitResp.VersionID(), chk.NotNil)
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ func Example() {
|
|||
|
||||
// Create the blob with string (plain text) content.
|
||||
data := "Hello World!"
|
||||
_, err = blobURL.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = blobURL.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -429,8 +429,7 @@ func ExampleContainerURL_SetContainerAccessPolicy() {
|
|||
blobURL := containerURL.NewBlockBlobURL("HelloWorld.txt") // Blob names can be mixed case
|
||||
|
||||
// Create the blob and put some text in it
|
||||
_, err = blobURL.Upload(ctx, strings.NewReader("Hello World!"), BlobHTTPHeaders{ContentType: "text/plain"},
|
||||
Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = blobURL.Upload(ctx, strings.NewReader("Hello World!"), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -494,7 +493,7 @@ func ExampleBlobAccessConditions() {
|
|||
}
|
||||
|
||||
// Create the blob (unconditionally; succeeds)
|
||||
upload, err := blobURL.Upload(ctx, strings.NewReader("Text-1"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
upload, err := blobURL.Upload(ctx, strings.NewReader("Text-1"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
showResult(upload, err)
|
||||
|
||||
// Download blob content if the blob has been modified since we uploaded it (fails):
|
||||
|
@ -506,8 +505,7 @@ func ExampleBlobAccessConditions() {
|
|||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: time.Now().UTC().Add(time.Hour * -24)}}, false))
|
||||
|
||||
// Upload new content if the blob hasn't changed since the version identified by ETag (succeeds):
|
||||
upload, err = blobURL.Upload(ctx, strings.NewReader("Text-2"), BlobHTTPHeaders{}, Metadata{},
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: upload.ETag()}}, DefaultAccessTier)
|
||||
upload, err = blobURL.Upload(ctx, strings.NewReader("Text-2"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: upload.ETag()}}, DefaultAccessTier, nil)
|
||||
showResult(upload, err)
|
||||
|
||||
// Download content if it has changed since the version identified by ETag (fails):
|
||||
|
@ -515,8 +513,7 @@ func ExampleBlobAccessConditions() {
|
|||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: upload.ETag()}}, false))
|
||||
|
||||
// Upload content if the blob doesn't already exist (fails):
|
||||
showResult(blobURL.Upload(ctx, strings.NewReader("Text-3"), BlobHTTPHeaders{}, Metadata{},
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETagAny}}, DefaultAccessTier))
|
||||
showResult(blobURL.Upload(ctx, strings.NewReader("Text-3"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETagAny}}, DefaultAccessTier, nil))
|
||||
}
|
||||
|
||||
// This examples shows how to create a container with metadata and then how to read & update the metadata.
|
||||
|
@ -585,8 +582,7 @@ func ExampleMetadata_blobs() {
|
|||
// NOTE: Metadata key names are always converted to lowercase before being sent to the Storage Service.
|
||||
// Therefore, you should always use lowercase letters; especially when querying a map for a metadata key.
|
||||
creatingApp, _ := os.Executable()
|
||||
_, err = blobURL.Upload(ctx, strings.NewReader("Some text"), BlobHTTPHeaders{},
|
||||
Metadata{"author": "Jeffrey", "app": creatingApp}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = blobURL.Upload(ctx, strings.NewReader("Some text"), BlobHTTPHeaders{}, Metadata{"author": "Jeffrey", "app": creatingApp}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -633,11 +629,10 @@ func ExampleBlobHTTPHeaders() {
|
|||
ctx := context.Background() // This example uses a never-expiring context
|
||||
|
||||
// Create a blob with HTTP headers
|
||||
_, err = blobURL.Upload(ctx, strings.NewReader("Some text"),
|
||||
BlobHTTPHeaders{
|
||||
ContentType: "text/html; charset=utf-8",
|
||||
ContentDisposition: "attachment",
|
||||
}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = blobURL.Upload(ctx, strings.NewReader("Some text"), BlobHTTPHeaders{
|
||||
ContentType: "text/html; charset=utf-8",
|
||||
ContentDisposition: "attachment",
|
||||
}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -716,7 +711,7 @@ func ExampleBlockBlobURL() {
|
|||
}
|
||||
|
||||
// After all the blocks are uploaded, atomically commit them to the blob.
|
||||
_, err = blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = blobURL.CommitBlockList(ctx, base64BlockIDs, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -759,7 +754,7 @@ func ExampleAppendBlobURL() {
|
|||
appendBlobURL := NewAppendBlobURL(*u, NewPipeline(credential, PipelineOptions{}))
|
||||
|
||||
ctx := context.Background() // This example uses a never-expiring context
|
||||
_, err = appendBlobURL.Create(ctx, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{})
|
||||
_, err = appendBlobURL.Create(ctx, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -799,8 +794,7 @@ func ExamplePageBlobURL() {
|
|||
blobURL := NewPageBlobURL(*u, NewPipeline(credential, PipelineOptions{}))
|
||||
|
||||
ctx := context.Background() // This example uses a never-expiring context
|
||||
_, err = blobURL.Create(ctx, PageBlobPageBytes*4, 0, BlobHTTPHeaders{},
|
||||
Metadata{}, BlobAccessConditions{}, DefaultPremiumBlobAccessTier)
|
||||
_, err = blobURL.Create(ctx, PageBlobPageBytes*4, 0, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -870,7 +864,7 @@ func Example_blobSnapshots() {
|
|||
ctx := context.Background() // This example uses a never-expiring context
|
||||
|
||||
// Create the original blob:
|
||||
_, err = baseBlobURL.Upload(ctx, strings.NewReader("Some text"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = baseBlobURL.Upload(ctx, strings.NewReader("Some text"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -880,7 +874,7 @@ func Example_blobSnapshots() {
|
|||
snapshot := createSnapshot.Snapshot()
|
||||
|
||||
// Modify the original blob & show it:
|
||||
_, err = baseBlobURL.Upload(ctx, strings.NewReader("New text"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = baseBlobURL.Upload(ctx, strings.NewReader("New text"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -928,7 +922,7 @@ func Example_blobSnapshots() {
|
|||
}
|
||||
|
||||
// Promote read-only snapshot to writable base blob:
|
||||
_, err = baseBlobURL.StartCopyFromURL(ctx, snapshotBlobURL.URL(), Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = baseBlobURL.StartCopyFromURL(ctx, snapshotBlobURL.URL(), Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -966,14 +960,12 @@ func Example_progressUploadDownload() {
|
|||
requestBody := strings.NewReader("Some text to write")
|
||||
|
||||
// Wrap the request body in a RequestBodyProgress and pass a callback function for progress reporting.
|
||||
_, err = blobURL.Upload(ctx,
|
||||
pipeline.NewRequestBodyProgress(requestBody, func(bytesTransferred int64) {
|
||||
fmt.Printf("Wrote %d of %d bytes.", bytesTransferred, requestBody.Size())
|
||||
}),
|
||||
BlobHTTPHeaders{
|
||||
ContentType: "text/html; charset=utf-8",
|
||||
ContentDisposition: "attachment",
|
||||
}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = blobURL.Upload(ctx, pipeline.NewRequestBodyProgress(requestBody, func(bytesTransferred int64) {
|
||||
fmt.Printf("Wrote %d of %d bytes.", bytesTransferred, requestBody.Size())
|
||||
}), BlobHTTPHeaders{
|
||||
ContentType: "text/html; charset=utf-8",
|
||||
ContentDisposition: "attachment",
|
||||
}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -1013,7 +1005,7 @@ func ExampleBlobURL_startCopy() {
|
|||
ctx := context.Background() // This example uses a never-expiring context
|
||||
|
||||
src, _ := url.Parse("https://cdn2.auth0.com/docs/media/addons/azure_blob.svg")
|
||||
startCopy, err := blobURL.StartCopyFromURL(ctx, *src, nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
startCopy, err := blobURL.StartCopyFromURL(ctx, *src, nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -1259,7 +1251,7 @@ func ExampleListBlobsHierarchy() {
|
|||
blobNames := []string{"a/1", "a/2", "b/1", "boaty_mcboatface"}
|
||||
for _, blobName := range blobNames {
|
||||
blobURL := containerURL.NewBlockBlobURL(blobName)
|
||||
_, err := blobURL.Upload(ctx, strings.NewReader("test"), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.Upload(ctx, strings.NewReader("test"), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal("an error occurred while creating blobs for the example setup")
|
||||
|
|
|
@ -24,7 +24,7 @@ func (s *aztestsSuite) TestSnapshotSAS(c *chk.C) {
|
|||
burl := containerURL.NewBlockBlobURL(blobName)
|
||||
data := "Hello world!"
|
||||
|
||||
_, err = burl.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = burl.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ func (s *aztestsSuite) TestSnapshotSAS(c *chk.C) {
|
|||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
time.Sleep(time.Second * 2)
|
||||
|
||||
//Attach SAS query to block blob URL
|
||||
p := NewPipeline(NewAnonymousCredential(), PipelineOptions{})
|
||||
|
@ -91,7 +92,7 @@ func (s *aztestsSuite) TestSnapshotSAS(c *chk.C) {
|
|||
//If this succeeds, it means a normal SAS token was created.
|
||||
|
||||
fsburl := containerURL.NewBlockBlobURL("failsnap")
|
||||
_, err = fsburl.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = fsburl.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
c.Fatal(err) //should succeed to create the blob via normal auth means
|
||||
}
|
||||
|
|
|
@ -166,8 +166,7 @@ func createNewContainerWithSuffix(c *chk.C, bsu ServiceURL, suffix string) (cont
|
|||
func createNewBlockBlob(c *chk.C, container ContainerURL) (blob BlockBlobURL, name string) {
|
||||
blob, name = getBlockBlobURL(c, container)
|
||||
|
||||
cResp, err := blob.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{},
|
||||
nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
cResp, err := blob.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(cResp.StatusCode(), chk.Equals, 201)
|
||||
|
@ -178,7 +177,7 @@ func createNewBlockBlob(c *chk.C, container ContainerURL) (blob BlockBlobURL, na
|
|||
func createNewAppendBlob(c *chk.C, container ContainerURL) (blob AppendBlobURL, name string) {
|
||||
blob, name = getAppendBlobURL(c, container)
|
||||
|
||||
resp, err := blob.Create(ctx, BlobHTTPHeaders{}, nil, BlobAccessConditions{})
|
||||
resp, err := blob.Create(ctx, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
|
||||
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.StatusCode(), chk.Equals, 201)
|
||||
|
@ -188,7 +187,7 @@ func createNewAppendBlob(c *chk.C, container ContainerURL) (blob AppendBlobURL,
|
|||
func createNewPageBlob(c *chk.C, container ContainerURL) (blob PageBlobURL, name string) {
|
||||
blob, name = getPageBlobURL(c, container)
|
||||
|
||||
resp, err := blob.Create(ctx, PageBlobPageBytes*10, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier)
|
||||
resp, err := blob.Create(ctx, PageBlobPageBytes*10, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.StatusCode(), chk.Equals, 201)
|
||||
return
|
||||
|
@ -197,7 +196,7 @@ func createNewPageBlob(c *chk.C, container ContainerURL) (blob PageBlobURL, name
|
|||
func createNewPageBlobWithSize(c *chk.C, container ContainerURL, sizeInBytes int64) (blob PageBlobURL, name string) {
|
||||
blob, name = getPageBlobURL(c, container)
|
||||
|
||||
resp, err := blob.Create(ctx, sizeInBytes, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier)
|
||||
resp, err := blob.Create(ctx, sizeInBytes, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
|
||||
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.StatusCode(), chk.Equals, 201)
|
||||
|
@ -208,8 +207,7 @@ func createBlockBlobWithPrefix(c *chk.C, container ContainerURL, prefix string)
|
|||
name = prefix + generateName(blobPrefix)
|
||||
blob = container.NewBlockBlobURL(name)
|
||||
|
||||
cResp, err := blob.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{},
|
||||
nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
cResp, err := blob.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(cResp.StatusCode(), chk.Equals, 201)
|
||||
|
|
|
@ -20,7 +20,7 @@ func (s *aztestsSuite) TestAppendBlock(c *chk.C) {
|
|||
|
||||
blob := container.NewAppendBlobURL(generateBlobName())
|
||||
|
||||
resp, err := blob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{})
|
||||
resp, err := blob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.StatusCode(), chk.Equals, 201)
|
||||
|
||||
|
@ -49,7 +49,7 @@ func (s *aztestsSuite) TestAppendBlockWithMD5(c *chk.C) {
|
|||
|
||||
// set up blob to test
|
||||
blob := container.NewAppendBlobURL(generateBlobName())
|
||||
resp, err := blob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{})
|
||||
resp, err := blob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.StatusCode(), chk.Equals, 201)
|
||||
|
||||
|
@ -91,7 +91,7 @@ func (s *aztestsSuite) TestAppendBlockFromURL(c *chk.C) {
|
|||
destBlob := container.NewAppendBlobURL(generateName("appenddest"))
|
||||
|
||||
// Prepare source blob for copy.
|
||||
cResp1, err := srcBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{})
|
||||
cResp1, err := srcBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(cResp1.StatusCode(), chk.Equals, 201)
|
||||
appendResp, err := srcBlob.AppendBlock(context.Background(), r, AppendBlobAccessConditions{}, nil)
|
||||
|
@ -123,7 +123,7 @@ func (s *aztestsSuite) TestAppendBlockFromURL(c *chk.C) {
|
|||
srcBlobURLWithSAS := srcBlobParts.URL()
|
||||
|
||||
// Append block from URL.
|
||||
cResp2, err := destBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{})
|
||||
cResp2, err := destBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(cResp2.StatusCode(), chk.Equals, 201)
|
||||
appendFromURLResp, err := destBlob.AppendBlockFromURL(ctx, srcBlobURLWithSAS, 0, int64(testSize), AppendBlobAccessConditions{}, ModifiedAccessConditions{}, nil)
|
||||
|
@ -163,7 +163,7 @@ func (s *aztestsSuite) TestAppendBlockFromURLWithMD5(c *chk.C) {
|
|||
destBlob := container.NewAppendBlobURL(generateName("appenddest"))
|
||||
|
||||
// Prepare source blob for copy.
|
||||
cResp1, err := srcBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{})
|
||||
cResp1, err := srcBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(cResp1.StatusCode(), chk.Equals, 201)
|
||||
appendResp, err := srcBlob.AppendBlock(context.Background(), r, AppendBlobAccessConditions{}, nil)
|
||||
|
@ -195,7 +195,7 @@ func (s *aztestsSuite) TestAppendBlockFromURLWithMD5(c *chk.C) {
|
|||
srcBlobURLWithSAS := srcBlobParts.URL()
|
||||
|
||||
// Append block from URL.
|
||||
cResp2, err := destBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{})
|
||||
cResp2, err := destBlob.Create(context.Background(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(cResp2.StatusCode(), chk.Equals, 201)
|
||||
appendFromURLResp, err := destBlob.AppendBlockFromURL(ctx, srcBlobURLWithSAS, 0, int64(testSize), AppendBlobAccessConditions{}, ModifiedAccessConditions{}, md5Value[:])
|
||||
|
@ -229,7 +229,7 @@ func (s *aztestsSuite) TestBlobCreateAppendMetadataNonEmpty(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getAppendBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{})
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -243,7 +243,7 @@ func (s *aztestsSuite) TestBlobCreateAppendMetadataEmpty(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getAppendBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{})
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -257,7 +257,7 @@ func (s *aztestsSuite) TestBlobCreateAppendMetadataInvalid(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getAppendBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, Metadata{"In valid!": "bar"}, BlobAccessConditions{})
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, Metadata{"In valid!": "bar"}, BlobAccessConditions{}, nil)
|
||||
c.Assert(strings.Contains(err.Error(), invalidHeaderErrorSubstring), chk.Equals, true)
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ func (s *aztestsSuite) TestBlobCreateAppendHTTPHeaders(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getAppendBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Create(ctx, basicHeaders, nil, BlobAccessConditions{})
|
||||
_, err := blobURL.Create(ctx, basicHeaders, nil, BlobAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -290,8 +290,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfModifiedSinceTrue(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(-10)
|
||||
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}})
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validateAppendBlobPut(c, blobURL)
|
||||
|
@ -305,8 +304,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfModifiedSinceFalse(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(10)
|
||||
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}})
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, nil)
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -318,8 +316,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfUnmodifiedSinceTrue(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(10)
|
||||
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}})
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validateAppendBlobPut(c, blobURL)
|
||||
|
@ -333,8 +330,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfUnmodifiedSinceFalse(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(-10)
|
||||
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}})
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, nil)
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -346,8 +342,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfMatchTrue(c *chk.C) {
|
|||
|
||||
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}})
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validateAppendBlobPut(c, blobURL)
|
||||
|
@ -359,8 +354,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfMatchFalse(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := createNewAppendBlob(c, containerURL)
|
||||
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}})
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, nil)
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -370,8 +364,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfNoneMatchTrue(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := createNewAppendBlob(c, containerURL)
|
||||
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}})
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validateAppendBlobPut(c, blobURL)
|
||||
|
@ -385,8 +378,7 @@ func (s *aztestsSuite) TestBlobCreateAppendIfNoneMatchFalse(c *chk.C) {
|
|||
|
||||
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}})
|
||||
_, err := blobURL.Create(ctx, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, nil)
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -622,4 +614,3 @@ func (s *aztestsSuite) TestBlobAppendBlockIfMaxSizeFalse(c *chk.C) {
|
|||
AppendBlobAccessConditions{AppendPositionAccessConditions: AppendPositionAccessConditions{IfMaxSizeLessThanOrEqual: int64(len(blockBlobDefaultData) - 1)}}, nil)
|
||||
validateStorageError(c, err, ServiceCodeMaxBlobSizeConditionNotMet)
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestEmpty(c *chk.C) {
|
|||
blobURL, _ := createNewBlockBlob(c, containerURL)
|
||||
copyBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
blobCopyResponse, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
blobCopyResponse, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
waitForCopy(c, copyBlobURL, blobCopyResponse)
|
||||
|
||||
|
@ -115,7 +115,7 @@ func (s *aztestsSuite) TestBlobStartCopyMetadata(c *chk.C) {
|
|||
blobURL, _ := createNewBlockBlob(c, containerURL)
|
||||
copyBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
resp, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
resp, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
waitForCopy(c, copyBlobURL, resp)
|
||||
|
||||
|
@ -132,11 +132,10 @@ func (s *aztestsSuite) TestBlobStartCopyMetadataNil(c *chk.C) {
|
|||
copyBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
// Have the destination start with metadata so we ensure the nil metadata passed later takes effect
|
||||
_, err := copyBlobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{},
|
||||
basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := copyBlobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
resp, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
waitForCopy(c, copyBlobURL, resp)
|
||||
|
@ -154,11 +153,10 @@ func (s *aztestsSuite) TestBlobStartCopyMetadataEmpty(c *chk.C) {
|
|||
copyBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
// Have the destination start with metadata so we ensure the empty metadata passed later takes effect
|
||||
_, err := copyBlobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{},
|
||||
basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := copyBlobURL.Upload(ctx, bytes.NewReader([]byte("data")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
resp, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
waitForCopy(c, copyBlobURL, resp)
|
||||
|
@ -175,7 +173,7 @@ func (s *aztestsSuite) TestBlobStartCopyMetadataInvalidField(c *chk.C) {
|
|||
blobURL, _ := createNewBlockBlob(c, containerURL)
|
||||
copyBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
_, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), Metadata{"I nvalid.": "bar"}, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), Metadata{"I nvalid.": "bar"}, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.NotNil)
|
||||
c.Assert(strings.Contains(err.Error(), invalidHeaderErrorSubstring), chk.Equals, true)
|
||||
}
|
||||
|
@ -187,7 +185,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceNonExistant(c *chk.C) {
|
|||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
copyBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
_, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeBlobNotFound)
|
||||
}
|
||||
|
||||
|
@ -211,7 +209,7 @@ func (s *aztestsSuite) TestBlobStartCopySourcePrivate(c *chk.C) {
|
|||
if bsu.String() == bsu2.String() {
|
||||
c.Skip("Test not valid because primary and secondary accounts are the same")
|
||||
}
|
||||
_, err = copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeCannotVerifyCopySource)
|
||||
}
|
||||
|
||||
|
@ -250,7 +248,7 @@ func (s *aztestsSuite) TestBlobStartCopyUsingSASSrc(c *chk.C) {
|
|||
defer deleteContainer(c, copyContainerURL)
|
||||
copyBlobURL, _ := getBlockBlobURL(c, copyContainerURL)
|
||||
|
||||
resp, err := copyBlobURL.StartCopyFromURL(ctx, sasURL, nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
resp, err := copyBlobURL.StartCopyFromURL(ctx, sasURL, nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
waitForCopy(c, copyBlobURL, resp)
|
||||
|
@ -321,7 +319,7 @@ func (s *aztestsSuite) TestBlobStartCopyUsingSASDest(c *chk.C) {
|
|||
srcBlobWithSasURL := blobURL.URL()
|
||||
srcBlobWithSasURL.RawQuery = queryParams.Encode()
|
||||
|
||||
resp, err := anonBlobURL.StartCopyFromURL(ctx, srcBlobWithSasURL, nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
resp, err := anonBlobURL.StartCopyFromURL(ctx, srcBlobWithSasURL, nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
// Allow copy to happen
|
||||
|
@ -346,9 +344,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfModifiedSinceTrue(c *chk.C) {
|
|||
blobURL, _ := createNewBlockBlob(c, containerURL)
|
||||
|
||||
destBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata,
|
||||
ModifiedAccessConditions{IfModifiedSince: currentTime},
|
||||
BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{IfModifiedSince: currentTime}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -365,9 +361,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfModifiedSinceFalse(c *chk.C) {
|
|||
currentTime := getRelativeTimeGMT(10)
|
||||
|
||||
destBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil,
|
||||
ModifiedAccessConditions{IfModifiedSince: currentTime},
|
||||
BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{IfModifiedSince: currentTime}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeSourceConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -380,9 +374,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfUnmodifiedSinceTrue(c *chk.C) {
|
|||
currentTime := getRelativeTimeGMT(10)
|
||||
|
||||
destBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata,
|
||||
ModifiedAccessConditions{IfUnmodifiedSince: currentTime},
|
||||
BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{IfUnmodifiedSince: currentTime}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -399,9 +391,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfUnmodifiedSinceFalse(c *chk.C) {
|
|||
currentTime := getRelativeTimeGMT(-10)
|
||||
|
||||
destBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil,
|
||||
ModifiedAccessConditions{IfUnmodifiedSince: currentTime},
|
||||
BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{IfUnmodifiedSince: currentTime}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeSourceConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -416,9 +406,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfMatchTrue(c *chk.C) {
|
|||
etag := resp.ETag()
|
||||
|
||||
destBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
_, err = destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata,
|
||||
ModifiedAccessConditions{IfMatch: etag},
|
||||
BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{IfMatch: etag}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp2, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -433,9 +421,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfMatchFalse(c *chk.C) {
|
|||
blobURL, _ := createNewBlockBlob(c, containerURL)
|
||||
|
||||
destBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata,
|
||||
ModifiedAccessConditions{IfMatch: "a"},
|
||||
BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{IfMatch: "a"}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeSourceConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -446,9 +432,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfNoneMatchTrue(c *chk.C) {
|
|||
blobURL, _ := createNewBlockBlob(c, containerURL)
|
||||
|
||||
destBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata,
|
||||
ModifiedAccessConditions{IfNoneMatch: "a"},
|
||||
BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{IfNoneMatch: "a"}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp2, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -467,9 +451,7 @@ func (s *aztestsSuite) TestBlobStartCopySourceIfNoneMatchFalse(c *chk.C) {
|
|||
etag := resp.ETag()
|
||||
|
||||
destBlobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
_, err = destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil,
|
||||
ModifiedAccessConditions{IfNoneMatch: etag},
|
||||
BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{IfNoneMatch: etag}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeSourceConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -481,9 +463,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfModifiedSinceTrue(c *chk.C) {
|
|||
blobURL, _ := createNewBlockBlob(c, containerURL)
|
||||
|
||||
destBlobURL, _ := createNewBlockBlob(c, containerURL) // The blob must exist to have a last-modified time
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata,
|
||||
ModifiedAccessConditions{},
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -500,9 +480,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfModifiedSinceFalse(c *chk.C) {
|
|||
destBlobURL, _ := createNewBlockBlob(c, containerURL)
|
||||
currentTime := getRelativeTimeGMT(10)
|
||||
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil,
|
||||
ModifiedAccessConditions{},
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeTargetConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -515,9 +493,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfUnmodifiedSinceTrue(c *chk.C) {
|
|||
destBlobURL, _ := createNewBlockBlob(c, containerURL)
|
||||
currentTime := getRelativeTimeGMT(10)
|
||||
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata,
|
||||
ModifiedAccessConditions{},
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -534,9 +510,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfUnmodifiedSinceFalse(c *chk.C) {
|
|||
currentTime := getRelativeTimeGMT(-10)
|
||||
destBlobURL, _ := createNewBlockBlob(c, containerURL)
|
||||
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil,
|
||||
ModifiedAccessConditions{},
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeTargetConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -550,9 +524,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfMatchTrue(c *chk.C) {
|
|||
resp, _ := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
etag := resp.ETag()
|
||||
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata,
|
||||
ModifiedAccessConditions{},
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: etag}}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: etag}}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err = destBlobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -572,8 +544,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfMatchFalse(c *chk.C) {
|
|||
|
||||
destBlobURL.SetMetadata(ctx, nil, BlobAccessConditions{}) // SetMetadata chances the blob's etag
|
||||
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{},
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: etag}}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: etag}}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeTargetConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -589,8 +560,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfNoneMatchTrue(c *chk.C) {
|
|||
|
||||
destBlobURL.SetMetadata(ctx, nil, BlobAccessConditions{}) // SetMetadata chances the blob's etag
|
||||
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{},
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: etag}}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), basicMetadata, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: etag}}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err = destBlobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -608,8 +578,7 @@ func (s *aztestsSuite) TestBlobStartCopyDestIfNoneMatchFalse(c *chk.C) {
|
|||
resp, _ := destBlobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
etag := resp.ETag()
|
||||
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{},
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: etag}}, DefaultAccessTier)
|
||||
_, err := destBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: etag}}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeTargetConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -625,7 +594,7 @@ func (s *aztestsSuite) TestBlobAbortCopyInProgress(c *chk.C) {
|
|||
for i := range blobData {
|
||||
blobData[i] = byte('a' + i%26)
|
||||
}
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(blobData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(blobData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
containerURL.SetAccessPolicy(ctx, PublicAccessBlob, nil, ContainerAccessConditions{}) // So that we don't have to create a SAS
|
||||
|
||||
|
@ -641,7 +610,7 @@ func (s *aztestsSuite) TestBlobAbortCopyInProgress(c *chk.C) {
|
|||
|
||||
defer deleteContainer(c, copyContainerURL)
|
||||
|
||||
resp, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
resp, err := copyBlobURL.StartCopyFromURL(ctx, blobURL.URL(), nil, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.CopyStatus(), chk.Equals, CopyStatusPending)
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ func (s *aztestsSuite) TestStageGetBlocks(c *chk.C) {
|
|||
c.Assert(blockList.CommittedBlocks, chk.HasLen, 0)
|
||||
c.Assert(blockList.UncommittedBlocks, chk.HasLen, 1)
|
||||
|
||||
listResp, err := blob.CommitBlockList(context.Background(), []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
listResp, err := blob.CommitBlockList(context.Background(), []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(listResp.Response().StatusCode, chk.Equals, 201)
|
||||
c.Assert(listResp.LastModified().IsZero(), chk.Equals, false)
|
||||
|
@ -88,7 +88,7 @@ func (s *aztestsSuite) TestStageBlockFromURL(c *chk.C) {
|
|||
destBlob := container.NewBlockBlobURL(generateBlobName())
|
||||
|
||||
// Prepare source blob for copy.
|
||||
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
|
||||
|
||||
|
@ -134,7 +134,7 @@ func (s *aztestsSuite) TestStageBlockFromURL(c *chk.C) {
|
|||
c.Assert(blockList.UncommittedBlocks, chk.HasLen, 2)
|
||||
|
||||
// Commit block list.
|
||||
listResp, err := destBlob.CommitBlockList(context.Background(), []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
listResp, err := destBlob.CommitBlockList(context.Background(), []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(listResp.Response().StatusCode, chk.Equals, 201)
|
||||
|
||||
|
@ -163,7 +163,7 @@ func (s *aztestsSuite) TestCopyBlockBlobFromURL(c *chk.C) {
|
|||
destBlob := container.NewBlockBlobURL(generateBlobName())
|
||||
|
||||
// Prepare source blob for copy.
|
||||
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
|
||||
|
||||
|
@ -184,7 +184,7 @@ func (s *aztestsSuite) TestCopyBlockBlobFromURL(c *chk.C) {
|
|||
srcBlobURLWithSAS := srcBlobParts.URL()
|
||||
|
||||
// Invoke copy blob from URL.
|
||||
resp, err := destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{"foo": "bar"}, ModifiedAccessConditions{}, BlobAccessConditions{}, sourceDataMD5Value[:], DefaultAccessTier)
|
||||
resp, err := destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{"foo": "bar"}, ModifiedAccessConditions{}, BlobAccessConditions{}, sourceDataMD5Value[:], DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.Response().StatusCode, chk.Equals, 202)
|
||||
c.Assert(resp.ETag(), chk.Not(chk.Equals), "")
|
||||
|
@ -207,11 +207,11 @@ func (s *aztestsSuite) TestCopyBlockBlobFromURL(c *chk.C) {
|
|||
|
||||
// Edge case 1: Provide bad MD5 and make sure the copy fails
|
||||
_, badMD5 := getRandomDataAndReader(16)
|
||||
_, err = destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, badMD5, DefaultAccessTier)
|
||||
_, err = destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, badMD5, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.NotNil)
|
||||
|
||||
// Edge case 2: Not providing any source MD5 should see the CRC getting returned instead
|
||||
resp, err = destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, nil, DefaultAccessTier)
|
||||
resp, err = destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, nil, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.Response().StatusCode, chk.Equals, 202)
|
||||
c.Assert(resp.XMsContentCrc64(), chk.Not(chk.Equals), "")
|
||||
|
@ -231,7 +231,7 @@ func (s *aztestsSuite) TestBlobSASQueryParamOverrideResponseHeaders(c *chk.C) {
|
|||
ctx := context.Background() // Use default Background context
|
||||
blob := container.NewBlockBlobURL(generateBlobName())
|
||||
|
||||
uploadResp, err := blob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
uploadResp, err := blob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(uploadResp.Response().StatusCode, chk.Equals, 201)
|
||||
|
||||
|
@ -303,7 +303,7 @@ func (s *aztestsSuite) TestBlobPutBlobNonEmptyBody(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.Upload(ctx, strings.NewReader(blockBlobDefaultData), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
|
||||
|
@ -318,7 +318,7 @@ func (s *aztestsSuite) TestBlobPutBlobHTTPHeaders(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), basicHeaders, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), basicHeaders, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -334,7 +334,7 @@ func (s *aztestsSuite) TestBlobPutBlobMetadataNotEmpty(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -348,7 +348,7 @@ func (s *aztestsSuite) TestBlobPutBlobMetadataEmpty(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -362,7 +362,7 @@ func (s *aztestsSuite) TestBlobPutBlobMetadataInvalid(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Upload(ctx, nil, BlobHTTPHeaders{}, Metadata{"In valid!": "bar"}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.Upload(ctx, nil, BlobHTTPHeaders{}, Metadata{"In valid!": "bar"}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(strings.Contains(err.Error(), validationErrorSubstring), chk.Equals, true)
|
||||
}
|
||||
|
||||
|
@ -374,8 +374,7 @@ func (s *aztestsSuite) TestBlobPutBlobIfModifiedSinceTrue(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(-10)
|
||||
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier)
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validateUpload(c, blobURL)
|
||||
|
@ -389,8 +388,7 @@ func (s *aztestsSuite) TestBlobPutBlobIfModifiedSinceFalse(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(10)
|
||||
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier)
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -402,8 +400,7 @@ func (s *aztestsSuite) TestBlobPutBlobIfUnmodifiedSinceTrue(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(10)
|
||||
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier)
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validateUpload(c, blobURL)
|
||||
|
@ -417,8 +414,7 @@ func (s *aztestsSuite) TestBlobPutBlobIfUnmodifiedSinceFalse(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(-10)
|
||||
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier)
|
||||
_, err := blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -431,8 +427,7 @@ func (s *aztestsSuite) TestBlobPutBlobIfMatchTrue(c *chk.C) {
|
|||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, DefaultAccessTier)
|
||||
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validateUpload(c, blobURL)
|
||||
|
@ -447,8 +442,7 @@ func (s *aztestsSuite) TestBlobPutBlobIfMatchFalse(c *chk.C) {
|
|||
_, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, DefaultAccessTier)
|
||||
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -461,8 +455,7 @@ func (s *aztestsSuite) TestBlobPutBlobIfNoneMatchTrue(c *chk.C) {
|
|||
_, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, DefaultAccessTier)
|
||||
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validateUpload(c, blobURL)
|
||||
|
@ -477,8 +470,7 @@ func (s *aztestsSuite) TestBlobPutBlobIfNoneMatchFalse(c *chk.C) {
|
|||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, DefaultAccessTier)
|
||||
_, err = blobURL.Upload(ctx, bytes.NewReader(nil), BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -529,7 +521,7 @@ func (s *aztestsSuite) TestBlobGetBlockListCommitted(c *chk.C) {
|
|||
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
|
||||
resp, err := blobURL.GetBlockList(ctx, BlockListCommitted, LeaseAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
@ -575,7 +567,7 @@ func (s *aztestsSuite) TestBlobGetBlockListBothNotEmpty(c *chk.C) {
|
|||
c.Assert(err, chk.IsNil)
|
||||
_, err = blobURL.StageBlock(ctx, id.next(), strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
_, err = blobURL.CommitBlockList(ctx, id.issued(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = blobURL.CommitBlockList(ctx, id.issued(), BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
// Put two uncommitted blocks
|
||||
|
@ -613,7 +605,7 @@ func (s *aztestsSuite) TestBlobGetBlockListSnapshot(c *chk.C) {
|
|||
|
||||
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.CreateSnapshot(ctx, nil, BlobAccessConditions{})
|
||||
|
@ -671,7 +663,7 @@ func (s *aztestsSuite) TestBlobPutBlockListInvalidID(c *chk.C) {
|
|||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id[:2]}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id[:2]}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeInvalidBlockID)
|
||||
}
|
||||
|
||||
|
@ -679,7 +671,7 @@ func (s *aztestsSuite) TestBlobPutBlockListDuplicateBlocks(c *chk.C) {
|
|||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id, id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id, id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetBlockList(ctx, BlockListAll, LeaseAccessConditions{})
|
||||
|
@ -691,7 +683,7 @@ func (s *aztestsSuite) TestBlobPutBlockListEmptyList(c *chk.C) {
|
|||
containerURL, blobURL, _ := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{}, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{}, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetBlockList(ctx, BlockListAll, LeaseAccessConditions{})
|
||||
|
@ -703,7 +695,7 @@ func (s *aztestsSuite) TestBlobPutBlockListMetadataEmpty(c *chk.C) {
|
|||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -715,7 +707,7 @@ func (s *aztestsSuite) TestBlobPutBlockListMetadataNonEmpty(c *chk.C) {
|
|||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -727,7 +719,7 @@ func (s *aztestsSuite) TestBlobPutBlockListHTTPHeaders(c *chk.C) {
|
|||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, basicHeaders, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, basicHeaders, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -739,10 +731,10 @@ func (s *aztestsSuite) TestBlobPutBlockListHTTPHeadersEmpty(c *chk.C) {
|
|||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{ContentDisposition: "my_disposition"}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{ContentDisposition: "my_disposition"}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -759,13 +751,12 @@ func validateBlobCommitted(c *chk.C, blobURL BlockBlobURL) {
|
|||
func (s *aztestsSuite) TestBlobPutBlockListIfModifiedSinceTrue(c *chk.C) {
|
||||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier) // The blob must actually exist to have a modifed time
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
currentTime := getRelativeTimeGMT(-10)
|
||||
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier)
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validateBlobCommitted(c, blobURL)
|
||||
|
@ -777,21 +768,19 @@ func (s *aztestsSuite) TestBlobPutBlockListIfModifiedSinceFalse(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(10)
|
||||
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestBlobPutBlockListIfUnmodifiedSinceTrue(c *chk.C) {
|
||||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier) // The blob must actually exist to have a modifed time
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
currentTime := getRelativeTimeGMT(10)
|
||||
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier)
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validateBlobCommitted(c, blobURL)
|
||||
|
@ -799,13 +788,12 @@ func (s *aztestsSuite) TestBlobPutBlockListIfUnmodifiedSinceTrue(c *chk.C) {
|
|||
|
||||
func (s *aztestsSuite) TestBlobPutBlockListIfUnmodifiedSinceFalse(c *chk.C) {
|
||||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier) // The blob must actually exist to have a modifed time
|
||||
blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
|
||||
defer deleteContainer(c, containerURL)
|
||||
|
||||
currentTime := getRelativeTimeGMT(-10)
|
||||
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultAccessTier, nil)
|
||||
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
@ -813,11 +801,10 @@ func (s *aztestsSuite) TestBlobPutBlockListIfUnmodifiedSinceFalse(c *chk.C) {
|
|||
func (s *aztestsSuite) TestBlobPutBlockListIfMatchTrue(c *chk.C) {
|
||||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
resp, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier) // The blob must actually exist to have a modifed time
|
||||
resp, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, DefaultAccessTier)
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validateBlobCommitted(c, blobURL)
|
||||
|
@ -826,11 +813,10 @@ func (s *aztestsSuite) TestBlobPutBlockListIfMatchTrue(c *chk.C) {
|
|||
func (s *aztestsSuite) TestBlobPutBlockListIfMatchFalse(c *chk.C) {
|
||||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier) // The blob must actually exist to have a modifed time
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, DefaultAccessTier)
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, DefaultAccessTier, nil)
|
||||
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
@ -838,11 +824,10 @@ func (s *aztestsSuite) TestBlobPutBlockListIfMatchFalse(c *chk.C) {
|
|||
func (s *aztestsSuite) TestBlobPutBlockListIfNoneMatchTrue(c *chk.C) {
|
||||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier) // The blob must actually exist to have a modifed time
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, DefaultAccessTier)
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validateBlobCommitted(c, blobURL)
|
||||
|
@ -851,11 +836,10 @@ func (s *aztestsSuite) TestBlobPutBlockListIfNoneMatchTrue(c *chk.C) {
|
|||
func (s *aztestsSuite) TestBlobPutBlockListIfNoneMatchFalse(c *chk.C) {
|
||||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
resp, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier) // The blob must actually exist to have a modifed time
|
||||
resp, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil) // The blob must actually exist to have a modifed time
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, DefaultAccessTier)
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, DefaultAccessTier, nil)
|
||||
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
@ -864,7 +848,7 @@ func (s *aztestsSuite) TestBlobPutBlockListValidateData(c *chk.C) {
|
|||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
|
||||
resp, err := blobURL.Download(ctx, 0, 0, BlobAccessConditions{}, false)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
@ -876,7 +860,7 @@ func (s *aztestsSuite) TestBlobPutBlockListModifyBlob(c *chk.C) {
|
|||
containerURL, blobURL, id := setupPutBlockListTest(c)
|
||||
defer deleteContainer(c, containerURL)
|
||||
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobURL.CommitBlockList(ctx, []string{id}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.StageBlock(ctx, "0001", bytes.NewReader([]byte("new data")), LeaseAccessConditions{}, nil)
|
||||
|
@ -888,7 +872,7 @@ func (s *aztestsSuite) TestBlobPutBlockListModifyBlob(c *chk.C) {
|
|||
_, err = blobURL.StageBlock(ctx, "0100", bytes.NewReader([]byte("new data")), LeaseAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{"0001", "0011"}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{"0001", "0011"}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetBlockList(ctx, BlockListAll, LeaseAccessConditions{})
|
||||
|
@ -906,7 +890,7 @@ func (s *aztestsSuite) TestSetTierOnBlobUpload(c *chk.C) {
|
|||
for _, tier := range []AccessTierType{AccessTierArchive, AccessTierCool, AccessTierHot} {
|
||||
blobURL, _ := getBlockBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Upload(ctx, strings.NewReader("Test Data"), basicHeaders, nil, BlobAccessConditions{}, tier)
|
||||
_, err := blobURL.Upload(ctx, strings.NewReader("Test Data"), basicHeaders, nil, BlobAccessConditions{}, tier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -926,7 +910,7 @@ func (s *aztestsSuite) TestBlobSetTierOnCommit(c *chk.C) {
|
|||
_, err := blobURL.StageBlock(ctx, blockID, strings.NewReader(blockBlobDefaultData), LeaseAccessConditions{}, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, tier)
|
||||
_, err = blobURL.CommitBlockList(ctx, []string{blockID}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, tier, nil)
|
||||
|
||||
resp, err := blobURL.GetBlockList(ctx, BlockListCommitted, LeaseAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
@ -939,7 +923,7 @@ func (s *aztestsSuite) TestSetTierOnCopyBlockBlobFromURL(c *chk.C) {
|
|||
bsu := getBSU()
|
||||
|
||||
container, _ := createNewContainer(c, bsu)
|
||||
//defer delContainer(c, container)
|
||||
defer delContainer(c, container)
|
||||
|
||||
testSize := 1 * 1024 * 1024
|
||||
r, sourceData := getRandomDataAndReader(testSize)
|
||||
|
@ -948,7 +932,7 @@ func (s *aztestsSuite) TestSetTierOnCopyBlockBlobFromURL(c *chk.C) {
|
|||
srcBlob := container.NewBlockBlobURL(generateBlobName())
|
||||
|
||||
// Setting blob tier as "cool"
|
||||
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, AccessTierCool)
|
||||
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, AccessTierCool, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
|
||||
|
||||
|
@ -973,7 +957,7 @@ func (s *aztestsSuite) TestSetTierOnCopyBlockBlobFromURL(c *chk.C) {
|
|||
srcBlobURLWithSAS := srcBlobParts.URL()
|
||||
for _, tier := range []AccessTierType{AccessTierArchive, AccessTierCool, AccessTierHot} {
|
||||
destBlob := container.NewBlockBlobURL(generateBlobName())
|
||||
resp, err := destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{"foo": "bar"}, ModifiedAccessConditions{}, BlobAccessConditions{}, sourceDataMD5Value[:], tier)
|
||||
resp, err := destBlob.CopyFromURL(ctx, srcBlobURLWithSAS, Metadata{"foo": "bar"}, ModifiedAccessConditions{}, BlobAccessConditions{}, sourceDataMD5Value[:], tier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp.Response().StatusCode, chk.Equals, 202)
|
||||
c.Assert(string(resp.CopyStatus()), chk.DeepEquals, "success")
|
||||
|
@ -1002,7 +986,7 @@ func (s *aztestsSuite) TestSetTierOnStageBlockFromURL(c *chk.C) {
|
|||
tier := AccessTierCool
|
||||
|
||||
// Prepare source blob for copy.
|
||||
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, tier)
|
||||
uploadSrcResp, err := srcBlob.Upload(ctx, r, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, tier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(uploadSrcResp.Response().StatusCode, chk.Equals, 201)
|
||||
|
||||
|
@ -1048,7 +1032,7 @@ func (s *aztestsSuite) TestSetTierOnStageBlockFromURL(c *chk.C) {
|
|||
c.Assert(blockList.UncommittedBlocks, chk.HasLen, 2)
|
||||
|
||||
// Commit block list.
|
||||
listResp, err := destBlob.CommitBlockList(context.Background(), []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, tier)
|
||||
listResp, err := destBlob.CommitBlockList(context.Background(), []string{blockID1, blockID2}, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, tier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(listResp.Response().StatusCode, chk.Equals, 201)
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ func (s *aztestsSuite) TestContainerCreateAccessContainer(c *chk.C) {
|
|||
c.Assert(err, chk.IsNil)
|
||||
|
||||
blobURL := containerURL.NewBlockBlobURL(blobPrefix)
|
||||
blobURL.Upload(ctx, bytes.NewReader([]byte("Content")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
blobURL.Upload(ctx, bytes.NewReader([]byte("Content")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
|
||||
// Anonymous enumeration should be valid with container access
|
||||
containerURL2 := NewContainerURL(containerURL.URL(), NewPipeline(NewAnonymousCredential(), PipelineOptions{}))
|
||||
|
@ -149,7 +149,7 @@ func (s *aztestsSuite) TestContainerCreateAccessBlob(c *chk.C) {
|
|||
c.Assert(err, chk.IsNil)
|
||||
|
||||
blobURL := containerURL.NewBlockBlobURL(blobPrefix)
|
||||
blobURL.Upload(ctx, bytes.NewReader([]byte("Content")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
blobURL.Upload(ctx, bytes.NewReader([]byte("Content")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
|
||||
// Reference the same container URL but with anonymous credentials
|
||||
containerURL2 := NewContainerURL(containerURL.URL(), NewPipeline(NewAnonymousCredential(), PipelineOptions{}))
|
||||
|
@ -171,7 +171,7 @@ func (s *aztestsSuite) TestContainerCreateAccessNone(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
|
||||
blobURL := containerURL.NewBlockBlobURL(blobPrefix)
|
||||
blobURL.Upload(ctx, bytes.NewReader([]byte("Content")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier)
|
||||
blobURL.Upload(ctx, bytes.NewReader([]byte("Content")), BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
|
||||
// Reference the same container URL but with anonymous credentials
|
||||
containerURL2 := NewContainerURL(containerURL.URL(), NewPipeline(NewAnonymousCredential(), PipelineOptions{}))
|
||||
|
@ -383,7 +383,7 @@ func (s *aztestsSuite) TestContainerListBlobsIncludeTypeCopy(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, blobName := createNewBlockBlob(c, containerURL)
|
||||
blobCopyURL, blobCopyName := createBlockBlobWithPrefix(c, containerURL, "copy")
|
||||
_, err := blobCopyURL.StartCopyFromURL(ctx, blobURL.URL(), Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err := blobCopyURL.StartCopyFromURL(ctx, blobURL.URL(), Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := containerURL.ListBlobsFlatSegment(ctx, Marker{},
|
||||
|
@ -457,7 +457,7 @@ func testContainerListBlobsIncludeMultipleImpl(c *chk.C, bsu ServiceURL) error {
|
|||
_, err := blobURL.CreateSnapshot(ctx, Metadata{}, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
blobURL2, _ := createBlockBlobWithPrefix(c, containerURL, "copy")
|
||||
resp2, err := blobURL2.StartCopyFromURL(ctx, blobURL.URL(), Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
resp2, err := blobURL2.StartCopyFromURL(ctx, blobURL.URL(), Metadata{}, ModifiedAccessConditions{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
waitForCopy(c, blobURL2, resp2)
|
||||
blobURL3, _ := createBlockBlobWithPrefix(c, containerURL, "deleted")
|
||||
|
|
|
@ -293,7 +293,7 @@ func (s *aztestsSuite) TestBlobCreatePageSizeInvalid(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getPageBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Create(ctx, 1, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier)
|
||||
_, err := blobURL.Create(ctx, 1, 0, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeInvalidHeaderValue)
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ func (s *aztestsSuite) TestBlobCreatePageSequenceInvalid(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getPageBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, -1, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, -1, BlobHTTPHeaders{}, nil, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
|
||||
c.Assert(err, chk.Not(chk.IsNil))
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ func (s *aztestsSuite) TestBlobCreatePageMetadataNonEmpty(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getPageBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultPremiumBlobAccessTier)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
@ -326,7 +326,7 @@ func (s *aztestsSuite) TestBlobCreatePageMetadataEmpty(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getPageBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultPremiumBlobAccessTier)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultPremiumBlobAccessTier, nil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
@ -339,7 +339,7 @@ func (s *aztestsSuite) TestBlobCreatePageMetadataInvalid(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getPageBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, Metadata{"In valid1": "bar"}, BlobAccessConditions{}, PremiumPageBlobAccessTierNone)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, Metadata{"In valid1": "bar"}, BlobAccessConditions{}, PremiumPageBlobAccessTierNone, nil)
|
||||
c.Assert(strings.Contains(err.Error(), invalidHeaderErrorSubstring), chk.Equals, true)
|
||||
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ func (s *aztestsSuite) TestBlobCreatePageHTTPHeaders(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := getPageBlobURL(c, containerURL)
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, basicHeaders, nil, BlobAccessConditions{}, PremiumPageBlobAccessTierNone)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, basicHeaders, nil, BlobAccessConditions{}, PremiumPageBlobAccessTierNone, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
resp, err := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
@ -373,8 +373,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfModifiedSinceTrue(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(-10)
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultPremiumBlobAccessTier)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultPremiumBlobAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validatePageBlobPut(c, blobURL)
|
||||
|
@ -388,8 +387,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfModifiedSinceFalse(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(10)
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultPremiumBlobAccessTier)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfModifiedSince: currentTime}}, DefaultPremiumBlobAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -401,8 +399,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfUnmodifiedSinceTrue(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(10)
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultPremiumBlobAccessTier)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultPremiumBlobAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validatePageBlobPut(c, blobURL)
|
||||
|
@ -416,8 +413,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfUnmodifiedSinceFalse(c *chk.C) {
|
|||
|
||||
currentTime := getRelativeTimeGMT(-10)
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultPremiumBlobAccessTier)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfUnmodifiedSince: currentTime}}, DefaultPremiumBlobAccessTier, nil)
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -429,8 +425,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfMatchTrue(c *chk.C) {
|
|||
|
||||
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, PremiumPageBlobAccessTierNone)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: resp.ETag()}}, PremiumPageBlobAccessTierNone, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validatePageBlobPut(c, blobURL)
|
||||
|
@ -442,8 +437,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfMatchFalse(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := createNewPageBlob(c, containerURL) // Originally created without metadata
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, PremiumPageBlobAccessTierNone)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfMatch: ETag("garbage")}}, PremiumPageBlobAccessTierNone, nil)
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
||||
|
@ -453,8 +447,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfNoneMatchTrue(c *chk.C) {
|
|||
defer deleteContainer(c, containerURL)
|
||||
blobURL, _ := createNewPageBlob(c, containerURL) // Originally created without metadata
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, PremiumPageBlobAccessTierNone)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: ETag("garbage")}}, PremiumPageBlobAccessTierNone, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
||||
validatePageBlobPut(c, blobURL)
|
||||
|
@ -468,8 +461,7 @@ func (s *aztestsSuite) TestBlobCreatePageIfNoneMatchFalse(c *chk.C) {
|
|||
|
||||
resp, _ := blobURL.GetProperties(ctx, BlobAccessConditions{})
|
||||
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata,
|
||||
BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, DefaultPremiumBlobAccessTier)
|
||||
_, err := blobURL.Create(ctx, PageBlobPageBytes, 0, BlobHTTPHeaders{}, basicMetadata, BlobAccessConditions{ModifiedAccessConditions: ModifiedAccessConditions{IfNoneMatch: resp.ETag()}}, DefaultPremiumBlobAccessTier, nil)
|
||||
|
||||
validateStorageError(c, err, ServiceCodeConditionNotMet)
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func (s *aztestsSuite) TestGetAccountInfo(c *chk.C) {
|
|||
|
||||
// test on a block blob URL. They all call the same thing on the base URL, so only one test is needed for that.
|
||||
bbURL := cURL.NewBlockBlobURL(generateBlobName())
|
||||
_, err = bbURL.Upload(ctx, strings.NewReader("blah"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = bbURL.Upload(ctx, strings.NewReader("blah"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
c.Assert(err, chk.IsNil)
|
||||
bAccInfo, err := bbURL.GetAccountInfo(ctx)
|
||||
c.Assert(err, chk.IsNil)
|
||||
|
|
|
@ -28,6 +28,7 @@ func (s *aztestsSuite) TestUserDelegationSASContainer(c *chk.C) {
|
|||
c.Fatal(err)
|
||||
}
|
||||
|
||||
// Prepare User Delegation SAS query
|
||||
cSAS, err := BlobSASSignatureValues{
|
||||
Protocol: SASProtocolHTTPS,
|
||||
StartTime: currentTime,
|
||||
|
@ -35,6 +36,9 @@ func (s *aztestsSuite) TestUserDelegationSASContainer(c *chk.C) {
|
|||
Permissions: "racwdl",
|
||||
ContainerName: containerName,
|
||||
}.NewSASQueryParameters(cudk)
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
// Create anonymous pipeline
|
||||
p = NewPipeline(NewAnonymousCredential(), PipelineOptions{})
|
||||
|
@ -52,7 +56,7 @@ func (s *aztestsSuite) TestUserDelegationSASContainer(c *chk.C) {
|
|||
cSASURL := NewContainerURL(cURL, p)
|
||||
|
||||
bblob := cSASURL.NewBlockBlobURL("test")
|
||||
_, err = bblob.Upload(ctx, strings.NewReader("hello world!"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = bblob.Upload(ctx, strings.NewReader("hello world!"), BlobHTTPHeaders{}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
@ -130,7 +134,7 @@ func (s *aztestsSuite) TestUserDelegationSASBlob(c *chk.C) {
|
|||
c.Fatal(err)
|
||||
}
|
||||
data := "Hello World!"
|
||||
_, err = blobURL.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier)
|
||||
_, err = blobURL.Upload(ctx, strings.NewReader(data), BlobHTTPHeaders{ContentType: "text/plain"}, Metadata{}, BlobAccessConditions{}, DefaultAccessTier, nil)
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче