2017-05-15 185 views
1

當我上傳了Azure存儲圖像,我做了這樣上傳圖像Azure存儲

let storageAccount : AZSCloudStorageAccount; 
      try! storageAccount = AZSCloudStorageAccount(fromConnectionString: config.getAzureConnection()) 

      let blobClient = storageAccount.getBlobClient() 

      var container : AZSCloudBlobContainer = (blobClient.containerReference(fromName: config.getImagesContainer())) 

      modelName = UIDevice.current.modelName 
      let ticks = Date().timeIntervalSince1970 * 1000 
      let imageName: String = "\(modelName)-\(ticks).png" 

      let blob: AZSCloudBlockBlob = container.blockBlobReference(fromName: imageName) 
      let imageData = UIImagePNGRepresentation(pickedImage) 

      blob.upload(from: imageData!, completionHandler:{(NSError) -> Void in 

      }) 

但是在Azure存儲的內容類型保存應用程序/八位字節流,而不是圖像/ PNG。我上傳圖片時如何更改內容類型?

回答

1

blob對象應該有一個名爲「屬性」的屬性。它應該是這樣的;

blob.Properties.ContentType =「image/png」;

+1

應該是'blob.properties.contentType' – ridvankucuk

+0

這個工程,謝謝 – HideCode