2016-11-12 51 views
0

我有一個要求,使用blob uri從臨時blob讀取文件並寫入其他blob。 我可以下載和上傳文件,但文件大小在存儲資源管理器中顯示爲0,如果我試圖打開/從資源管理器下載獲取編碼錯誤。Azure:下載文件上傳到azure blob存儲時的大小0和編碼錯誤

我的代碼

StorageCredentials storageCredentials = new StorageCredentials("AccountName", "Accountkey"); 

CloudBlockBlob blob = new CloudBlockBlob(new Uri(message), storageCredentials); 

blob.Properties.ContentType = "application/pdf"; 

using (MemoryStream ms = new MemoryStream()) 

{ 

blob.DownloadToStream(ms); 

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(AzureStorageConnectionString); 

CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); 

CloudBlobContainer container = blobClient.GetContainerReference("BlobPDF"); 

CloudBlockBlob targetblob = container.GetBlockBlobReference("test123.pdf"); 

targetblob.Properties.ContentType = "application/pdf"; 

targetblob.UploadFromStream(ms); 

} 
+0

上傳前,剛剛成立的 'MS' 的位置爲0。這應該夠了吧。 –

回答

相關問題