コード例 #1
0
        /// <summary>
        /// Returns the canonical name for shared access.
        /// </summary>
        /// <returns>The canonical name.</returns>
        private string GetSharedAccessCanonicalName()
        {
            string accountName   = this.ServiceClient.Credentials.AccountName ?? NavigationHelper.GetAccountNameFromUri(this.ServiceClient.BaseUri, null);
            string containerName = this.Name;

            string canonicalNameFormat = "/{0}/{1}/{2}";

            return(string.Format(CultureInfo.InvariantCulture, canonicalNameFormat, SR.Blob, accountName, containerName));
        }
コード例 #2
0
        public void GetAccountNameFromUriContainerQueryString()
        {
            // Arrange
            string uriString = "https://account.blob.core.windows.net/container?comp";

            // Act
            string accountName = NavigationHelper.GetAccountNameFromUri(new Uri(uriString), null);

            // Assert
            Assert.AreEqual("account", accountName);
        }
コード例 #3
0
        public void GetAccountNameFromUriIPStyleBlobQuery()
        {
            // Arrange
            string uriString = "https://105.232.1.23/account/container/blob?comp";

            // Act
            string accountName = NavigationHelper.GetAccountNameFromUri(new Uri(uriString), true);

            // Assert
            Assert.AreEqual("account", accountName);
        }
コード例 #4
0
        public void GetAccountNameFromUriIPStyleAccount()
        {
            // Arrange
            string uriString = "https://105.232.1.23/account";

            // Act
            string accountName = NavigationHelper.GetAccountNameFromUri(new Uri(uriString), null);

            // Assert
            Assert.AreEqual("account", accountName);
        }
コード例 #5
0
        public CloudTableClient(StorageUri storageUri, StorageCredentials credentials)
#endif
        {
            this.StorageUri           = storageUri;
            this.Credentials          = credentials ?? new StorageCredentials();
            this.RetryPolicy          = new ExponentialRetry();
            this.LocationMode         = LocationMode.PrimaryOnly;
            this.ServerTimeout        = Constants.DefaultServerSideTimeout;
            this.AuthenticationScheme = AuthenticationScheme.SharedKey;
            this.UsePathStyleUris     = CommonUtility.UsePathStyleAddressing(this.BaseUri);

            if (!this.Credentials.IsSharedKey)
            {
                this.AccountName = NavigationHelper.GetAccountNameFromUri(this.BaseUri, this.UsePathStyleUris);
            }
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CloudTableClient"/> class using the specified Table service endpoint
        /// and account credentials.
        /// </summary>
        /// <param name="storageUri">A <see cref="StorageUri"/> object containing the Table service endpoint to use to create the client.</param>
        /// <param name="credentials">A <see cref="StorageCredentials"/> object.</param>
        public CloudTableClient(StorageUri storageUri, StorageCredentials credentials)
        {
            this.StorageUri            = storageUri;
            this.Credentials           = credentials ?? new StorageCredentials();
            this.DefaultRequestOptions =
                new TableRequestOptions(TableRequestOptions.BaseDefaultRequestOptions)
            {
                RetryPolicy = new ExponentialRetry()
            };
            this.AuthenticationScheme = AuthenticationScheme.SharedKey;
            this.UsePathStyleUris     = CommonUtility.UsePathStyleAddressing(this.BaseUri);

            if (!this.Credentials.IsSharedKey)
            {
                this.AccountName = NavigationHelper.GetAccountNameFromUri(this.BaseUri, this.UsePathStyleUris);
            }
        }
コード例 #7
0
        public CloudTableClient(StorageUri storageUri, StorageCredentials credentials)
#endif
        {
            this.StorageUri                          = storageUri;
            this.Credentials                         = credentials ?? new StorageCredentials();
            this.DefaultRequestOptions               = new TableRequestOptions();
            this.DefaultRequestOptions.RetryPolicy   = new ExponentialRetry();
            this.DefaultRequestOptions.LocationMode  = RetryPolicies.LocationMode.PrimaryOnly;
            this.DefaultRequestOptions.PayloadFormat = TablePayloadFormat.Json;
            this.AuthenticationScheme                = AuthenticationScheme.SharedKey;
            this.UsePathStyleUris                    = CommonUtility.UsePathStyleAddressing(this.BaseUri);

            if (!this.Credentials.IsSharedKey)
            {
                this.AccountName = NavigationHelper.GetAccountNameFromUri(this.BaseUri, this.UsePathStyleUris);
            }
        }
コード例 #8
0
        /// <summary>
        /// Gets the canonical name of the blob, formatted as blob/&lt;account-name&gt;/&lt;container-name&gt;/&lt;blob-name&gt;.
        /// If <c>ignoreSnapshotTime</c> is <c>false</c> and this blob is a snapshot, the canonical name is augmented with a
        /// query of the form ?snapshot=&lt;snapshot-time&gt;.
        /// <para>This is used by both Shared Access and Copy blob operations.</para>
        /// </summary>
        /// <param name="ignoreSnapshotTime">Indicates if the snapshot time is ignored.</param>
        /// <returns>The canonical name of the blob.</returns>
        private string GetCanonicalName(bool ignoreSnapshotTime)
        {
            string accountName   = this.ServiceClient.Credentials.AccountName ?? NavigationHelper.GetAccountNameFromUri(this.ServiceClient.BaseUri, null);
            string containerName = this.Container.Name;

            // Replace \ with / for uri compatibility when running under .net 4.5.
            string blobName            = this.Name.Replace('\\', '/');
            string canonicalNameFormat = "/{0}/{1}/{2}/{3}";
            string canonicalName       = string.Format(CultureInfo.InvariantCulture, canonicalNameFormat, SR.Blob, accountName, containerName, blobName);

            if (!ignoreSnapshotTime && this.SnapshotTime != null)
            {
                canonicalName += "?snapshot=" + Request.ConvertDateTimeToSnapshotString(this.SnapshotTime.Value);
            }

            return(canonicalName);
        }