我经常需要在我的应用中显示一些加载行为,并且我想在完成工作后将其解雇 - 无论工作成果是成功还是错误 。因此,我最终得到了这样的代码:
addDisposable(router.launchHomepage()
.compose(loadingView.show()))
.subscribe(
{ loadingView.dismiss() },
{ loadingView.dismiss() }
)
)
有没有办法在单个方法中解除加载视图?与onComplete()
类似,但无论结果是成功还是错误都会调用?
答案 0 :(得分:2)
创建课程
public string GetBlobSasUri(string containerName, string blobName, string connectionstring)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionstring);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference(containerName);
CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName);
//Set the expiry time and permissions for the blob.
//In this case no start time is specified, so the shared access signature becomes valid immediately.
SharedAccessBlobPolicy sasConstraints = new SharedAccessBlobPolicy();
sasConstraints.SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(10);
sasConstraints.Permissions = SharedAccessBlobPermissions.Read;
//Generate the shared access signature on the blob, setting the constraints directly on the signature.
string sasContainerToken = blockBlob.GetSharedAccessSignature(sasConstraints);
//Return the URI string for the blob, including the SAS token.
return blockBlob.Uri + sasContainerToken;
}
并使用
public ActionResult FileDownload()
{
string blobURL = GetBlobSasUri("blob name","container name", "connection string");
return Redirect(blobURL);
}