Search code examples
swiftfirebase-storage

heic images are saved as application/octet-stream


I am trying to upload HEIC pictures to Firebase, but they are shown to have "application/octet-stream" type in the console, and all EXIF metadata is gone. Is this working as intended?

This is how I do the upload:

func upload(image: UIImage) async throws -> URL {
  let data = image.heicData()!
  _ = try await storage.reference().child("path/to/image.heic")
  return try await path.downloadURL()
}

Solution

  • It is working as intended.

    Firebase Storage doesn't attempt to interpret in any way the file or bytes that you upload. It is all just bytes, and that's what "application/octet-stream" means. To Firebase, EXIF metadata is just more bytes in the file.

    If you download the file again, it will still contain exactly everything you uploaded, including whatever metadata was embedded in the file.

    If you want to record metadata or change the content type in Storage as part of the upload, you are free to do that yourself using the provided API as shown in the documentation. But none of that will change the content that was uploaded or downloaded, because those bytes will never change.