当我将图像上传到 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 存储中,内容类型保存为 application/octet-stream 而不是 image/PNG。上传图片时如何更改内容类型?
最佳答案
blob 对象应该有一个名为“Properties”的属性。应该是这样的;
blob.Properties.ContentType = "image/png";
关于swift - 将图像上传到 Azure 存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43982079/