コード例 #1
0
        public ActionResult Share(string partitionKey, string rowKey)
        {
            var cloudTableClient = new CloudTableClient(this.UriTable, new StorageCredentials(this.AuthenticatedTableSas));
            var photoContext = new PhotoDataServiceContext(cloudTableClient);

            PhotoEntity photo = photoContext.GetById(partitionKey, rowKey);
            if (photo == null)
            {
                return this.HttpNotFound();
            }

            string sas = string.Empty;
            if (!string.IsNullOrEmpty(photo.BlobReference))
            {
                CloudBlockBlob blobBlockReference = this.GetBlobContainer().GetBlockBlobReference(photo.BlobReference);
                sas = photoContext.GetSasForBlob(blobBlockReference, SharedAccessBlobPermissions.Read);
            }

            if (!string.IsNullOrEmpty(sas))
            {
                return View("Share", null, sas);
            }

            return RedirectToAction("Index");
        }