我想在我的MVC项目中创建我的视图的PDF并将其保存到Azure blob存储中,而无需在我的服务器上有该文件的副本。使用rotativa创建pdf并保存到Azure blob
我正在使用Rotativa来创建我的pdf,这工作正常。
return new ActionAsPdf(ContractVersion) { FileName = "documentname.pdf" };
我使用下面的代码将文件保存到Azure存储。
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve a reference to a container.
CloudBlobContainer container = blobClient.GetContainerReference("contracts");
// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob");
// Create or overwrite the "myblob" blob with contents from a local file.
using (var fileStream = System.IO.File.OpenRead(@"c:\test blob.txt"))
{
blockBlob.UploadFromStream(fileStream);
}
但我不知道如何把两种功能共同创建PDF格式,然后保存到团块。
我希望我的问题清楚。感谢预期。
感谢您的帮助。我想我有几个选择?我可以在我的服务器上创建一个文件,将其上传到blob,然后再次删除它。或者,也许我可以尝试寻找另一种pdfwriter。什么是推荐的方法?我是这方面的新手,从来没有真正保存过服务器文件,所以我不想走错路。再次感谢。 – Ste