Пример #1
0
        /// <summary>Initializes a new instance of the <see cref="BlobAttributes"/> class from an existing <see cref="BlobAttributes"/> object.</summary>
        /// <param name="other">The set of blob attributes to clone. </param>
        public BlobAttributes(BlobAttributes other)
        {
            this.Properties = new BlobProperties(other.Properties);

            if (other.Metadata != null)
            {
                this.Metadata = new NameValueCollection(other.Metadata);
            }

            this.Snapshot = other.Snapshot;
            this.Uri = other.Uri;
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudPageBlob"/> class.
 /// </summary>
 /// <param name="attributes">The attributes.</param>
 /// <param name="serviceClient">The service client.</param>
 /// <param name="snapshotTime">The snapshot time.</param>
 internal CloudPageBlob(BlobAttributes attributes, CloudBlobClient serviceClient, string snapshotTime)
     : base(attributes, serviceClient, snapshotTime)
 {
     this.Properties.BlobType = BlobType.PageBlob;
 }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CloudBlob"/> class with existing attributes.
        /// </summary>
        /// <param name="attributes">The attributes (NOTE: Saved by reference, does not make a copy).</param>
        /// <param name="serviceClient">The service client.</param>
        /// <param name="snapshotTime">The snapshot time.</param>
        internal CloudBlob(BlobAttributes attributes, CloudBlobClient serviceClient, string snapshotTime)
        {
            this.attributes = attributes;
            this.ServiceClient = serviceClient;

            this.ParseQueryAndVerify(attributes.Uri, this.ServiceClient, this.ServiceClient.UsePathStyleUris);

            if (!string.IsNullOrEmpty(snapshotTime))
            {
                this.SnapshotTime = this.ParseSnapshotTime(snapshotTime);
            }
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CloudBlob"/> class with the given absolute Uri.
        /// </summary>
        /// <param name="usePathStyleUris">True to use path style Uris.</param>
        /// <param name="blobAbsoluteUri">The absolute blob Uri.</param>
        internal CloudBlob(bool? usePathStyleUris, string blobAbsoluteUri)
        {
            CommonUtils.AssertNotNullOrEmpty("blobAbsoluteUriString", blobAbsoluteUri);

            this.attributes = new BlobAttributes();

            var completeUri = new Uri(blobAbsoluteUri);

            this.ParseQueryAndVerify(completeUri, null, usePathStyleUris);
        }
Пример #5
0
        /// <summary>
        /// Implementation for the CreateSnapshot method.
        /// </summary>
        /// <param name="metadata">A collection of name-value pairs defining the metadata of the snapshot, or null.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <param name="setResult">The result report delegate.</param>
        /// <returns>A <see cref="TaskSequence"/> that creates the snapshot.</returns>
        /// <remarks>If the <c>metadata</c> parameter is <c>null</c> then no metadata is associated with the request.</remarks>
        private TaskSequence CreateSnapshotImpl(NameValueCollection metadata, BlobRequestOptions options, Action<CloudBlob> setResult)
        {
            CommonUtils.AssertNotNull("options", options);

            var webRequest = ProtocolHelper.GetWebRequest(
                this.ServiceClient,
                options,
                (timeout) => BlobRequest.Snapshot(this.TransformedAddress, timeout));

            BlobAttributes snapshotAttributes = new BlobAttributes(this.attributes);

            // If metadata was supplied it should be passed to the request.
            // Otherwise, no metadata should be sent.
            if (metadata != null)
            {
                BlobRequest.AddMetadata(webRequest, metadata);

                // Update the snapshot's attributes to reflect the new metadata.
                snapshotAttributes.Metadata.Clear();
                snapshotAttributes.Metadata.Add(metadata);
            }

            this.ServiceClient.Credentials.SignRequest(webRequest);

            var task = webRequest.GetResponseAsyncWithTimeout(this.ServiceClient, options.Timeout);

            yield return task;

            using (var webResponse = task.Result as HttpWebResponse)
            {
                string snapshotTime = BlobResponse.GetSnapshotTime(webResponse);

                CloudBlob snapshot = new CloudBlob(snapshotAttributes, this.ServiceClient, snapshotTime);

                snapshot.ParseSizeAndLastModified(webResponse);

                setResult(snapshot);
            }
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CloudBlob"/> class based on an existing instance.
        /// </summary>
        /// <param name="cloudBlob">An existing reference to a blob.</param>
        public CloudBlob(CloudBlob cloudBlob)
        {
            this.attributes = cloudBlob.Attributes;
            this.container = cloudBlob.container;
            this.parent = cloudBlob.parent;

            this.ServiceClient = cloudBlob.ServiceClient;
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CloudBlob"/> class using a relative URI to the blob, and the snapshot timestamp,
        /// if the blob is a snapshot.
        /// </summary>
        /// <param name="blobUri">The relative URI to the blob, beginning with the container name.</param>
        /// <param name="snapshotTime">The snapshot timestamp, if the blob is a snapshot.</param>
        /// <param name="serviceClient">A client object that specifies the endpoint for the Blob service.</param>
        public CloudBlob(string blobUri, DateTime? snapshotTime, CloudBlobClient serviceClient)
        {
            CommonUtils.AssertNotNullOrEmpty("blobAbsoluteUri", blobUri);
            CommonUtils.AssertNotNull("serviceClient", serviceClient);

            this.attributes = new BlobAttributes();
            this.ServiceClient = serviceClient;

            var completeUri = NavigationHelper.AppendPathToUri(this.ServiceClient.BaseUri, blobUri);

            this.ParseQueryAndVerify(completeUri, this.ServiceClient, this.ServiceClient.UsePathStyleUris);

            if (snapshotTime != null)
            {
                if (this.SnapshotTime != null)
                {
                    throw new ArgumentException(SR.SnapshotTimePassedTwice);
                }
                else
                {
                    this.SnapshotTime = snapshotTime;
                }
            }
        }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudPageBlob"/> class.
 /// </summary>
 /// <param name="attributes">The attributes.</param>
 /// <param name="serviceClient">The service client.</param>
 /// <param name="snapshotTime">The snapshot time.</param>
 internal CloudPageBlob(BlobAttributes attributes, CloudBlobClient serviceClient, string snapshotTime)
     : base(attributes, serviceClient, snapshotTime)
 {
     this.Properties.BlobType = BlobType.PageBlob;
 }