NodeJS client for SeaweedFS
$ npm install @trubavuong/seaweedfs
const { BlockStorage } = require('@trubavuong/seaweedfs');
const blockStorage = new BlockStorage('http://localhost:9333');
await blockStorage.ping();
/*
{
fid: '5,012d21951980',
url: '192.168.0.105:3838',
publicUrl: '192.168.0.105:3838',
count: 10,
}
*/
const result = await blockStorage.reserve(10);
/*
{
eTag: 'b85365fc',
fid: '1,013aeeb4df9c',
fileName: 'block-storage.test.js',
fileUrl: '192.168.0.105:3838/1,013aeeb4df9c',
size: 10352,
}
*/
const result = await blockStorage.add(fileData);
/*
{
fid: '1,013aeeb4df9c', // added by this lib
name: 'block-storage.test.js',
size: 10352,
eTag: 'b85365fc',
}
*/
const result = await blockStorage.replace(fid, fileData);
const fileStream = await blockStorage.get(fid);
await blockStorage.delete(fid);