yakovkhalinsky / backblaze-b2

Node.js Library for the Backblaze B2 Storage Service
MIT License
189 stars 58 forks source link

Find specific file using b2.listFileNames return files not relevant #119

Open XDavidT opened 2 years ago

XDavidT commented 2 years ago

I uploaded some files, delete some and so on, after my B2 was empty from files at all, I ask wanted to get a specific file, by file name, using the function b2.listFileNames and got a file that did not exists, also the name wasn't match. And no, the name wasn't matched in any part of it, my file name is hash of text, so the hash was completely different. How can I avoid this issue and why does it's happening? Right now I made something like this, but it's feel wrong:

        const getFiles = await b2.listFileNames({
            bucketId: <bucket-id>,
            maxFileCount:2,
            startFileName:filename
        })
        for(let file of getFiles.data.files){
           if(file.fileName === filename){
               return b2Config.getFileURL + file.fileId
           }
        }

I don't want to find all files, I want specific file. Is there any option to query specific one?