caiyue1993/IceCream

filePath issue of CreamAsset

owenzhao opened this issue · 0 comments

In CreamAsset's create methods, it allows to save file to places other than the default place. with public static func create(objectID: String, propName: String, url: URL, shouldOverwrite: Bool = true) -> CreamAsset?.

However, the filePath: URL property is incorrect.

/// Where the asset locates in the file system
public var filePath: URL {
    return CreamAsset.creamAssetDefaultURL().appendingPathComponent(uniqueFileName)
}

It always indicates that assets are saved in the default place. However, this may not be true. For example, if someone uses shared group container, which is common when developing Extensions like Share Extension and Today Extension, the saving place will not be the default place.

I have just made a small patch for this. Just changing the computed filePath to lazy property and assign the value when a url is given explicitly.