コード例 #1
0
        /// <summary>
        /// Parse URI for SAS (Shared Access Signature) and snapshot information.
        /// </summary>
        /// <param name="address">The complete Uri.</param>
        /// <param name="credentials">The credentials to use.</param>
        private void ParseQueryAndVerify(StorageUri address, StorageCredentials credentials)
        {
            StorageCredentials parsedCredentials;
            DateTimeOffset?    parsedSnapshot;

            this.attributes.StorageUri = NavigationHelper.ParseBlobQueryAndVerify(address, out parsedCredentials, out parsedSnapshot);

            if ((parsedCredentials != null) && (credentials != null) && !parsedCredentials.Equals(credentials))
            {
                string error = string.Format(CultureInfo.CurrentCulture, SR.MultipleCredentialsProvided);
                throw new ArgumentException(error);
            }

            if (parsedSnapshot.HasValue && this.SnapshotTime.HasValue && !parsedSnapshot.Value.Equals(this.SnapshotTime.Value))
            {
                string error = string.Format(CultureInfo.CurrentCulture, SR.MultipleSnapshotTimesProvided, parsedSnapshot, this.SnapshotTime);
                throw new ArgumentException(error);
            }

            if (parsedSnapshot.HasValue)
            {
                this.SnapshotTime = parsedSnapshot;
            }

            if (this.ServiceClient == null)
            {
                this.ServiceClient = new CloudBlobClient(NavigationHelper.GetServiceClientBaseAddress(this.StorageUri, null /* usePathStyleUris */), credentials ?? parsedCredentials);
            }

            this.Name = NavigationHelper.GetBlobName(this.Uri, this.ServiceClient.UsePathStyleUris);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CloudBlockBlob"/> class using the specified blob name and
        /// the parent container reference.
        /// If snapshotTime is not null, the blob instance represents a Snapshot.
        /// </summary>
        /// <param name="blobName">Name of the blob.</param>
        /// <param name="snapshotTime">Snapshot time in case the blob is a snapshot.</param>
        /// <param name="container">The reference to the parent container.</param>
        internal CloudBlockBlob(string blobName, DateTimeOffset?snapshotTime, CloudBlobContainer container)
        {
            CommonUtility.AssertNotNullOrEmpty("blobName", blobName);
            CommonUtility.AssertNotNull("container", container);

            this.attributes            = new BlobAttributes();
            this.attributes.StorageUri = NavigationHelper.AppendPathToUri(container.StorageUri, blobName);
            this.ServiceClient         = container.ServiceClient;

            // Set the relativized name from the URI.
            this.Name                = NavigationHelper.GetBlobName(this.attributes.Uri, this.ServiceClient.UsePathStyleUris);
            this.container           = container;
            this.SnapshotTime        = snapshotTime;
            this.Properties.BlobType = BlobType.BlockBlob;
        }