Este tópico ainda não foi avaliado como - Avalie este tópico

Propriedade BlobRequestOptions.CopySourceAccessCondition

[Este tópico é uma documentação de pré-lançamento e está sujeito a alterações em versões futuras. Os tópicos em branco são incluídos como espaços reservados.]

Gets or sets the access condition on the source blob, when the request is to copy a blob.

Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (em microsoft.windowsazure.storageclient.dll)
'Uso
Dim instance As BlobRequestOptions
Dim value As AccessCondition

value = instance.CopySourceAccessCondition

instance.CopySourceAccessCondition = value
public AccessCondition CopySourceAccessCondition { get; set; }
/** @property */
/** @attribute CompilerGeneratedAttribute() */ 
public AccessCondition get_CopySourceAccessCondition ()

/** @property */
/** @attribute CompilerGeneratedAttribute() */ 
public void set_CopySourceAccessCondition (AccessCondition value)

CompilerGeneratedAttribute 
public function get CopySourceAccessCondition () : AccessCondition

CompilerGeneratedAttribute 
public function set CopySourceAccessCondition (value : AccessCondition)

Valor de propriedade

Type: AccessCondition

A structure that specifies any conditional parameters on the request.

The following code example checks an access condition on the source blob and copies the blob if the condition is met.

static void CopyOnLastModifiedCondition(Uri blobEndpoint, string accountName, string accountKey)
{
    //Create service client for credentialed access to the Blob service.
    CloudBlobClient blobClient = new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey));

    //Get a reference to the source blob.
    CloudBlob sourceBlob = blobClient.GetBlobReference("mycontainer/myblob.txt");

    sourceBlob.FetchAttributes();

    //Get a reference to the destination blob.
    CloudBlob destBlob = blobClient.GetBlobReference("mycontainer/copy-if-modified-since.txt");

    BlobRequestOptions options = new BlobRequestOptions();
    DateTime dt = new DateTime(2010, 9, 1, 0, 0, 0, DateTimeKind.Utc);

    //Copy the source blob to the destination blob if the source blob has been modified since 9/1/2010.
    try
    {
        //Copy the source blob to the destination blob if the source blob has been modified since 9/1/2010.
        options.CopySourceAccessCondition = AccessCondition.IfModifiedSince(dt.ToUniversalTime());
        destBlob.CopyFromBlob(sourceBlob, options);
    }
    catch (StorageClientException e)
    {
        if (e.StatusCode == HttpStatusCode.PreconditionFailed)
        {
            Console.WriteLine("Access condition not met - blob " + sourceBlob.Uri + " has not been modified since " + dt.ToUniversalTime());
        }
        else
        {
            Console.WriteLine("Error code: " + e.ErrorCode);
        }
    }

    //Get a reference to the destination blob.
    destBlob = blobClient.GetBlobReference("mycontainer/copy-if-not-modified-since.txt");
    try
    {
        //Copy the source blob to the destination blob if the source blob has not been modified since 9/1/2010.
        options.CopySourceAccessCondition = AccessCondition.IfNotModifiedSince(dt.ToUniversalTime());
        destBlob.CopyFromBlob(sourceBlob, options);
    }
    catch (StorageClientException e)
    {
        if (e.StatusCode == HttpStatusCode.PreconditionFailed)
        {
            Console.WriteLine("Access condition not met - ETag for blob " + sourceBlob.Uri + " does not match ETag for blob " + destBlob.Uri);
        }
        else
        {
            Console.WriteLine("Error code: " + e.ErrorCode);
        }
    }
}


This property is applicable only to a request that will copy a blob.

The default access condition for any request to copy a blob is None.

An access condition may specify a condition that must be met for the copy operation to be performed by the service. The AccessCondition structure provides methods that can be used to specify exactly one of the following access conditions:

  • IfMatch, which performs a copy operation only if the specified Etag value matches the blob's Etag value.

  • IfNoneMatch, which performs a copy operation only if the specified Etag value does not match the blob's Etag value.

  • IfModifiedSince, which performs a copy operation only if the resource has been modified since the specified date and time.

  • IfNotModifiedSince, which performs a copy operation only if the resource has not been modified since the specified date and time.


Todos os membros estáticos públicos (Compartilhados no Visual Basic) desse tipo são thread-safe. Quaisquer membros de instância não têm garantia de ser thread-safe.

Plataformas de desenvolvimento

Windows XP Professional com Service Pack 2 (SP2)

Plataformas de destino

Isso foi útil para você?
(1500 caracteres restantes)

Contribuições da comunidade

© 2013 Microsoft. Todos os direitos reservados.
facebook page visit twitter rss feed newsletter