コード例 #1
0
        public async Task <bool> VerifyResourceExists(UserContentType contentType, Guid contentGuid)
        {
            //Container name format is {contentType}s.
            CloudBlobContainer container = BlobClient.GetContainerReference($"{contentType.ToString()}s");

            SharedAccessBlobPolicy sasConstraints = new SharedAccessBlobPolicy();

            sasConstraints.SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(30);
            sasConstraints.Permissions            = SharedAccessBlobPermissions.Read;  //download or retrievial should be READ ONLY.

            return(await container.GetBlockBlobReference($"{contentGuid.ToString()}.bin")
                   .ExistsAsync());
        }
コード例 #2
0
        public async Task <string> BuildRetrivalUrl(UserContentType contentType, Guid key)
        {
            //Container name format is {contentType}s.
            CloudBlobContainer container = BlobClient.GetContainerReference($"{contentType.ToString().ToLower()}s");

            SharedAccessBlobPolicy sasConstraints = new SharedAccessBlobPolicy();

            sasConstraints.SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(30);
            sasConstraints.Permissions            = SharedAccessBlobPermissions.Read;  //download or retrievial should be READ ONLY.

            ICloudBlob blob = await container.GetBlobReferenceFromServerAsync($"{key.ToString()}.bin");

            return(new Uri(blob.Uri, blob.GetSharedAccessSignature(sasConstraints)).ToString());
        }
コード例 #3
0
        public async Task <string> BuildUploadUrl(UserContentType contentType, Guid key)
        {
            //Container name format is {contentType}s.
            CloudBlobContainer container = BlobClient.GetContainerReference($"{contentType.ToString().ToLower()}s");

            SharedAccessBlobPolicy sasConstraints = new SharedAccessBlobPolicy();

            sasConstraints.SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(30);
            sasConstraints.Permissions            = SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.Create;

            ICloudBlob blob = container.GetBlockBlobReference($"{key.ToString()}.bin");

            return(new Uri(blob.Uri, blob.GetSharedAccessSignature(sasConstraints)).ToString());
        }