Start a new topic

All downloaded KCSFiles have property metadata = nil

Hi, the code (Swift) is below, thanks for the help!


  

var skip: Int = 0
    
    func fetchImages(completion:(status: String, fetchedImages: [Image]?) -> Void)
    {
        let query = KCSQuery()
            query.limitModifer = KCSQueryLimitModifier(limit: 8)
            query.skipModifier = KCSQuerySkipModifier(withcount: skip)
        
        KCSFileStore.downloadDataByQuery(query,
            completionBlock: {
                
                (downloadedResources: [AnyObject]!, error: NSError!) -> Void in
                
                guard error == nil else
                {
                    completion(status: "Error", fetchedImages: nil)
                    return
                }
                
                guard downloadedResources.count > 0 else
                {
                    completion(status: "No results", fetchedImages: nil)
                    return
                }
                
                var images = [Image]()
                
                for resource in downloadedResources
                {
                    print("resource => \(resource)")
                    
                    let file = resource as! KCSFile
                    
                    var creationTime: NSDate? = nil
                    if file.metadata != nil
                    {
                        creationTime = file.metadata.creationTime()
                    }
                    else
                    {
                        print("file.metadata == nil\n")
                    }
                    
                    let imgObj = Image(fileId: file.fileId,
                                    imageData: file.data,
                                 creationDate: creationTime)
                    images.append(imgObj)
                }
                
                self.skip += 8
                completion(status: "Success", fetchedImages: images)
            },
            progressBlock: nil
        )
    }

  

1 Comment

Nissi,


I will convey the issue you are facing to our engineering team and get back to you when I have more information on it.


Thanks,

Pranav

Kinvey Support

Login or Signup to post a comment