yakovkhalinsky / backblaze-b2

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

Options misssing for the listFileVersions function #91

Open michel-smarticket opened 4 years ago

michel-smarticket commented 4 years ago

Hello,

I've noticed the prefix and delimiter options are missing from the listFileVersions function. This raises an issue when trying to filter specific files from backblaze.

Proposed change:

exports.listFileVersions = function(b2, args) {
    const bucketId = args.bucketId;
    const startFileName = args.startFileName;
    const startFileId = args.startFileId;
    const maxFileCount = args.maxFileCount;
    const prefix = args.prefix;
    const delimiter = args.delimiter;

    const options = {
        url: endpoints(b2).listFileVersionsUrl,
        method: 'POST',
        headers: utils.getAuthHeaderObjectWithToken(b2),
        data: {
            bucketId: bucketId,
            startFileName: startFileName || '',
            prefix: prefix || '',
            delimiter: delimiter || null,
            startFileId: startFileId,
            maxFileCount: maxFileCount || 100
        }
    };

    // merge order matters here: later objects override earlier objects
    return request.sendRequest(_.merge({},
        _.get(args, 'axios', {}),
        options,
        _.get(args, 'axiosOverride', {})
    ));
};
RayRemnant commented 4 years ago

I think this is pretty important, I've done the same changes in order to use the listFileVersions as intended. Without the prefix and delimiter parameters you need additional work to select the versions of a single file.