Example #1
0
        public static UriBuilder GetRedirectUriBuilder(string method,
                                                       string scheme,
                                                       CloudStorageAccount account,
                                                       string containerName,
                                                       string blobName,
                                                       bool useSas,
                                                       string queryString,
                                                       bool decodeQueryParams = true)
        {
            CloudBlobContainer container = NamespaceHandler.GetContainerByName(account, containerName);
            // Strip any existing SAS query params as we'll replace them with our own SAS calculation
            var queryParams = RequestQueryParameters.Create(queryString, decodeQueryParams);

            SharedAccessSignature.RemoveSasQueryParameters(queryParams);
            if (useSas)
            {
                // Be careful to preserve the URL encoding in the signature
                queryParams.Append(CalculateSASStringForContainer(method, container), false);
            }
            return(new UriBuilder
            {
                Scheme = scheme,
                Host = account.BlobEndpoint.Host,
                Path = PathUtils.CombineContainerAndBlob(containerName, PathUtils.PathEncode(blobName)),
                Query = queryParams.ToString(),
            });
        }