public Models.CloudBlobCollection GetBlobsSharedAccessSignatures(string containerName, string blobPrefix, bool useFlatBlobListing) { // Authenticate. var userId = this.UserId; this.requestValidator.OnValidateRequest(userId, containerName); if (!string.IsNullOrEmpty(blobPrefix)) { blobPrefix = blobPrefix.TrimStart('/', '\\').Replace('\\', '/'); } try { var container = this.cloudBlobClient.GetContainerReference(containerName); container.CreateIfNotExist(); SetReadOnlySharedAccessPolicy(container); var prefix = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", containerName, blobPrefix); var blobs = this.cloudBlobClient.ListBlobsWithPrefix(prefix, new BlobRequestOptions { UseFlatBlobListing = useFlatBlobListing }); var result = new Models.CloudBlobCollection { Blobs = blobs.Where(b => b is CloudBlob) .Select(b => b.ToModel(containerName, this.cloudBlobClient.Credentials.AccountName)) .ToArray() }; if (this.webOperationContext != null) { this.webOperationContext.OutgoingResponse.Headers.Add("Cache-Control", "no-cache"); } return(result); } catch (Exception exception) { throw new WebFaultException <string>(exception.Message, HttpStatusCode.InternalServerError); } }
public Models.CloudBlobCollection GetBlobsSharedAccessSignatures(string blobPrefix, bool useFlatBlobListing) { // Authenticate. var userId = this.UserId; if (!string.IsNullOrEmpty(blobPrefix)) { blobPrefix = blobPrefix.TrimStart('/', '\\').Replace('\\', '/'); } try { // Each user has its own container. SetReadOnlySharedAccessPolicy(this.GetUserContainer(userId)); var prefix = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", GetUserContainerName(userId), blobPrefix); var blobs = this.cloudBlobClient.ListBlobsWithPrefix(prefix, new BlobRequestOptions { UseFlatBlobListing = useFlatBlobListing }); var result = new Models.CloudBlobCollection { Blobs = blobs.Where(b => b is CloudBlob) .Select(b => b.ToModel(GetUserContainerName(userId), this.cloudBlobClient.Credentials.AccountName)) .ToArray() }; if (this.webOperationContext != null) { this.webOperationContext.OutgoingResponse.Headers.Add("Cache-Control", "no-cache"); } return result; } catch (Exception exception) { throw new WebFaultException<string>(exception.Message, HttpStatusCode.InternalServerError); } }