0
我使用WinZip創建了一個zip文件。我可以使用WinZip和Windows資源管理器打開它。azure存儲上傳壓縮文件,然後再次下載並損壞
然後,我將該文件上傳到Azure存儲並再次下載。
我可以在Windows資源管理器中打開下載的文件,但WinZip說它已損壞。
我使用Windows 8.1和最新版本的Winzip。這發生在開發和生活環境中。這裏有什麼問題?
UPDATE 14/01/2014 這裏是我的代碼使用
Private Sub UploadDocumentToAzure(filename As String, _
ByRef stream As Stream)
Dim storageAccount As CloudStorageAccount = CloudStorageAccount.Parse(Microsoft.WindowsAzure.CloudConfigurationManager.GetSetting("StorageConnectionString"))
Dim blobClient As CloudBlobClient = storageAccount.CreateCloudBlobClient
Dim container As CloudBlobContainer = blobClient.GetContainerReference("cont")
container.CreateIfNotExists()
Dim blockBlob As CloudBlockBlob = container.GetBlockBlobReference(filename)
blockBlob.UploadFromStream(stream)
End Sub
Public Sub DownloadDocumentFromAzure(documentName As String, ByRef response As HttpResponse)
Dim storageAccount As CloudStorageAccount = CloudStorageAccount.Parse(Microsoft.WindowsAzure.CloudConfigurationManager.GetSetting("StorageConnectionString"))
Dim blobClient As CloudBlobClient = storageAccount.CreateCloudBlobClient
Dim container As CloudBlobContainer = blobClient.GetContainerReference("cont")
Dim blockBlob As CloudBlockBlob = container.GetBlockBlobReference(documentName)
Dim memStream As New MemoryStream
blockBlob.DownloadToStream(memStream)
response.ContentType = blockBlob.Properties.ContentType
response.AddHeader("Content-Disposition", "Attachment; filename=""" & blockBlob.Name.ToString() & """")
response.AddHeader("Content-Length", (blockBlob.Properties.Length - 1).ToString())
response.BinaryWrite(memStream.ToArray())
response.End()
End Sub
你是如何上傳文件 - 通過代碼或使用某種工具?它使用你寫的一些代碼,你可以分享嗎? –
該文件正在通過代碼上傳和下載。這裏是一些代碼片段:編輯 - 我將在上面添加它,以便我可以格式化代碼。 – jagdipa
是否有任何理由將你的下載函數中響應的內容長度設置爲'blockBlob.Properties.Length - 1'?它不應該是'blockBlob.Properties.Length'? –