2017-05-15 151 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