I'm trying to upload pictures to firebase with a mime type of image/jpeg but for some reason they all upload as application/octet-stream.
我试图用mime类型的图像/jpeg将图片上传到firebase,但是出于某种原因,它们都以应用程序/octet-stream的形式上传。
Heres my code snippet:
这是我的代码片段:
let storageRef = Storage.storage().reference().child("ProfilePictures/\(image).jpg")
if let uploadData = UIImageJPEGRepresentation(self.pickedImage!, 0.5){
storageRef.putData(uploadData, metadata: nil, completion:{ (metadata, error) in })
I got the image through a picker from the photo gallery
我从图片库的一个拾取者那里得到了这张照片
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let editedImage = info[UIImagePickerControllerEditedImage] as? UIImage {
ImageButton.setBackgroundImage(editedImage, for: .normal)
ImageButton.setTitle("", for: .normal)
self.pickedImage = editedImage
}
dismiss(animated: true, completion: nil)
}
1 个解决方案
#1
1
You have to set the metadata for the same.
您必须将元数据设置为相同的值。
Try it.
试一试。
metadata = { contentType: 'image/jpeg'};
元数据= {contentType: 'image/jpeg'};
#1
1
You have to set the metadata for the same.
您必须将元数据设置为相同的值。
Try it.
试一试。
metadata = { contentType: 'image/jpeg'};
元数据= {contentType: 'image/jpeg'};