Start a new topic

Getting the file URL

 Hi! First let me say to you that I'm just starting to migrate from Parse and you have to work on your Guides. Parse is a lot more clear in most everything in their documentation. I think you should give examples right after you explain the code. Right now I'm having trouble getting the file url. This is my code:


var query = new Kinvey.Query();
    query.equalTo('nombre1', 'Dan');
    var promise = Kinvey.DataStore.find('miembros', query);
    promise.then(function(entities) {
        var promiseFoto = Kinvey.File.downloadByUrl(entities[0].foto);
        promiseFoto.then(function(file) {
            // entity.logo === file.
            console.log("foto url : " + file);
        }, function(error) {
           console.log("Error con url : " + error.description);
    }, function(error) {
        alert("Error ENTITIES");

 The "console.log(entities[0].foto) is giving me an object and I want the url of the file.

I already figured it out



If you figured out the issue, can you share it so other people could be helped?

I'm guessing that you were after Entities[0].foto.downloadURL ?

I use this code for uploading a blob:


var promiseFile = Kinvey.File.upload(blob);
           promiseFile.then(function(file) {

             var entity = {
               nombre1  : nombre1,
               nombre2 : nombre2,
               apellido1 : apellido1,
               apellido2 : apellido2,
               correo : correo,
               rut : rut,
               bautizado : bautizado,
               discipulado : discipulado,
               direccion : direccion,
               telefono_casa : telefono,
               telefono_celular : celular,
               comuna : comuna,
               fecha_nac : fecha,
               mes_cumpleanos : mesCumple,
               ano_ingreso : añoIngreso,
               autor : usuarioActivo.username,

                foto: {
                    _type : 'KinveyFile',
                    _id : file._id

              var promiseS ='miembros', entity);
              promiseS.then(function(entity) {
                  console.log("Usuario agregado con éxito!");

              }, function(error) {
                  console.log("Problema agregando al usuario. Error : " + error.description);

           }, function(error) {
             console.log("Problema al subir la foto. Error: " + error.description);

 The problem was that I wasn't setting the file._id


Login or Signup to post a comment