我想在我的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