/// <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)); }
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); }
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); }
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); }
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); } }
/// <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); } }
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); } }
/// <summary> /// Gets the canonical name of the blob, formatted as blob/<account-name>/<container-name>/<blob-name>. /// 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=<snapshot-time>. /// <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); }