caiyue1993/IceCream

CreamAsset file extension

Fonceur opened this issue · 4 comments

This is related to #208 and #209.

While an image can be loaded just fine through Data(contentsOf: filePath), regardless of its file extension, it is not the case when dealing with other file types (i.e. .pdf, .xls, .doc, etc.). The lack of file extension makes it a problem when trying to pass the resulting URL (i.e. asset.filePath) to another framework/application, like say Apple QuickLook Preview. Same thing trying to share that file.

My initial implementation involved using ckRecord.setObject() and ckRecord.getObject(), but maybe there is a less invasive way.

As a work around, I've been creating symbolic links when accessing those files, which works fine with QLPreview on a device but not in a simulator. Unfortunately, the sharing from QLPreview doesn't seem to pass the actual file.

How about storing file extension as a property in the outside Object model? And you could retrieve the filePath of the CreamAsset and join together then pass to QLPreview so that make it work.

If we append the extension to the url provided by the CreamAsset, then that url doesn't point to an actual file... I did try something similar with the symbolic link, but it had its limitations.

Maybe you can try to copy/rename/move the origin file to your custom path? Since IceCream provides the filePath already.

I guess that extra processing could be done every time the file is updated, which is every time the app is launched, as delta updates aren't working...

Or it could be done only when access to the file is needed, at the cost of some extra delays to manipulate the file...

But in the end, with both your solution and mine, the file extension still ends up being written in the CKRecord of the parent...