/// <summary> /// Ensure the <see cref="BlobSasBuilder"/>'s properties are in a /// consistent state. /// </summary> private void EnsureState() { // Container if (String.IsNullOrEmpty(this.BlobName)) { // Make sure the permission characters are in the correct order this.Permissions = ContainerSasPermissions.Parse(this.Permissions).ToString(); this.Resource = Constants.Sas.Resource.Container; } // Blob or Snapshot else { // Blob if (String.IsNullOrEmpty(this.Snapshot)) { // Make sure the permission characters are in the correct order this.Permissions = BlobSasPermissions.Parse(this.Permissions).ToString(); this.Resource = Constants.Sas.Resource.Blob; } // Snapshot else { // Make sure the permission characters are in the correct order this.Permissions = SnapshotSasPermissions.Parse(this.Permissions).ToString(); this.Resource = Constants.Sas.Resource.BlobSnapshot; } } if (String.IsNullOrEmpty(this.Version)) { this.Version = SasQueryParameters.DefaultSasVersion; } }
/// <summary> /// Sets the permissions for a blob SAS. /// </summary> /// <param name="permissions"> /// <see cref="BlobSasPermissions"/> containing the allowed permissions. /// </param> public void SetPermissions(BlobSasPermissions permissions) { Permissions = permissions.ToPermissionsString(); }
/// <summary> /// Initializes a new instance of the <see cref="BlobSasBuilder"/> /// class to create a Blob Service Sas. /// </summary> /// <param name="permissions"> /// The time at which the shared access signature becomes invalid. /// This field must be omitted if it has been specified in an /// associated stored access policy. /// </param> /// <param name="expiresOn"> /// The time at which the shared access signature becomes invalid. /// This field must be omitted if it has been specified in an /// associated stored access policy. /// </param> public BlobSasBuilder(BlobSasPermissions permissions, DateTimeOffset expiresOn) { ExpiresOn = expiresOn; SetPermissions(permissions); }