Start a new topic

passing undefined as id to file stream, runs the success callback with array of all images objects

Hi, I am trying to use the `Kinvey.File.stream` and I pass a backbonejs attribute which contains the image_id and sometimes be `undefined`. The returned result `response` in success callback is an array containing all the image objects stored in google store. here's my code: category_icon_id = @get "category_icon_file" #when undefined promise1 = Kinvey.File.stream( category_icon_id, success: (file) -> #file is an array of all image objects retrieved from . options.primaryImg.onSuccess error: (error) -> options.primaryImg.onError error ) This makes a heavy load which I don't need.
1 Comment

Good morning NouranMahmoud, The reason why you are seeing all the items in your google cloud storage returned is because undefined will not filter the incoming query. You are probably trying to do something similar to: function loadImage(category_icon_id) { if (category_icon_id === undefined) { category_icon_id = this.get("category_icon_file"); } ... } The function above will ensure that you are not passing undefined values in to your GCS call. Thanks,
Login or Signup to post a comment