Esempio n. 1
0
            public Uri GetSas(Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions permission, TimeSpan expiry, string containerName)
            {
                var policy = new Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy
                {
                    Permissions            = permission,
                    SharedAccessExpiryTime = DateTime.UtcNow.Add(expiry)
                };
                var container = this.Parent.GetContainer(containerName);
                var signature = container.GetSharedAccessSignature(policy);

                return(new Uri(System.IO.Path.Combine(container.Uri.ToString(), signature)));
            }
        // source: http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-shared-access-signature-part-2/
        private string GetURL(int expirySeconds, Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions permissions)
        {
            var sasConstraints = new Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy();

            sasConstraints.SharedAccessStartTime  = DateTimeOffset.Now.AddMinutes(-1);
            sasConstraints.SharedAccessExpiryTime = DateTimeOffset.Now.AddSeconds(expirySeconds);
            sasConstraints.Permissions            = permissions;

            var sasToken = _delegateContent.GetSharedAccessSignature(sasConstraints);

            return(_delegateContent.Uri + sasToken);
        }