userSession.listFiles only returns 1 file - when many exist

I’ve tried to debug this every way I can think… But no matter what I do, listFiles will only return a single file that’s in GaiaHub. getFile and putFile work great - the app functions exactly as expected, except for when I listFiles.

Any one have thoughts on what I could be doing wrong or a similar experience?

I don’t have the time to test this, but the instructions say to send in a callback function that returns true in order to continue listing files: http://blockstack.github.io/blockstack.js/globals.html#listfiles

listFiles(callback: function, caller?: UserSession): Promise<number>

I would start with:

listFiles((filename) => {console.log(filename); return true})
1 Like

BOOM! thank you @colealbon

return new Promise((resolve, reject) => {
    let files = [];
    blockstack.listFiles((file) => {
       files.push(file);
       return true;
    }).then(() => {
        resolve(files);
    }).catch(reject);
});

EDIT: First one was wrong.

2 Likes