HideCode
HideCode

Reputation: 173

Upload image to Azure Storage

When I upload the image for the azure storage, I made that way

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

            })

But in azure storage the content type saved with application/octet-stream instead image/PNG. How can I change the content type when I upload the image?

Upvotes: 1

Views: 822

Answers (1)

MonkeyDLuffy
MonkeyDLuffy

Reputation: 657

The blob object should have a property called "Properties". It should be like;

blob.Properties.ContentType = "image/png";

Upvotes: 3

Related Questions