SkygearIO / skygear-SDK-iOS

Skygear SDK for iOS
https://skygear.io
Other
10 stars 28 forks source link

SKYAsset unable to derive mimeType from data #133

Closed Steven-Chan closed 7 years ago

Steven-Chan commented 7 years ago

Example code:

    func attachmentFor(image: UIImage) -> SKYAsset {
        let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
        let data = UIImageJPEGRepresentation(image, 0.8)
        // return SKYAsset(data: data!)
        // return SKYAsset(name: UUID().uuidString + ".jpg", data: data!)
    }

The data is generated from UIImageJPEGRepresentation, so I expect the SKYAsset can derive the correct mimeType no matter what, but it can't for neither of the following constructor.

return SKYAsset(data: data!)
return SKYAsset(name: UUID().uuidString + ".jpg", data: data!)
Steven-Chan commented 7 years ago

see https://github.com/aidansteele/MagicKit