/// <summary>
        /// Implements the DeleteBlob method.
        /// </summary>
        /// <param name="deleteSnapshotsOption">Whether to only delete the blob, to delete the blob and all snapshots, or to only delete the snapshots.</param>
        /// <param name="accessCondition">An object that represents the access conditions for the blob. If null, no condition is used.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <returns>A <see cref="RESTCommand"/> that deletes the blob.</returns>
        internal static RESTCommand <NullType> DeleteBlobImpl(ICloudBlob blob, BlobAttributes attributes, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options)
        {
            RESTCommand <NullType> deleteCmd = new RESTCommand <NullType>(blob.ServiceClient.Credentials, attributes.Uri);

            deleteCmd.ApplyRequestOptions(options);
            deleteCmd.Handler            = blob.ServiceClient.AuthenticationHandler;
            deleteCmd.BuildClient        = HttpClientFactory.BuildHttpClient;
            deleteCmd.BuildRequest       = (cmd, cnt, ctx) => BlobHttpRequestMessageFactory.Delete(cmd.Uri, cmd.ServerTimeoutInSeconds, attributes.SnapshotTime, deleteSnapshotsOption, accessCondition, cnt, ctx);
            deleteCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.Accepted, resp, NullType.Value, cmd, ex, ctx);

            return(deleteCmd);
        }
Пример #2
0
        public static HttpRequestMessage DeleteBlobRequest(BlobContext context, string containerName, string blobName, AccessCondition accessCondition)
        {
            Uri uri = BlobClientTests.ConstructUri(context.Address, containerName, blobName);
            OperationContext   opContext = new OperationContext();
            HttpRequestMessage request   = BlobHttpRequestMessageFactory.Delete(uri, context.Timeout, null /* snapshot */, DeleteSnapshotsOption.None, accessCondition, null,
                                                                                opContext,
                                                                                SharedKeyCanonicalizer.Instance,
                                                                                context.Credentials);

            Assert.IsNotNull(request);
            Assert.IsNotNull(request.Method);
            Assert.AreEqual(HttpMethod.Delete, request.Method);
            BlobTestUtils.RangeHeader(request, null);
            BlobTestUtils.LeaseIdHeader(request, null);
            return(request);
        }