0.0.3 • Published 4 years ago
@soeren_balke/file-system-lib v0.0.3
NodeJS Library for File System
Requirements
You need an instance of SB File System. This System should be accessible via https / http.
Custom import for each single functions:
const {
setConfig,
File
} = require('file-system-lib');
All in one:
const fileSystem = require('file-system-lib');
Config:
First of all you must set your configs to the lib: For the next example, we used the all in one import.
fileSystem.setConfig({
access: '916b47f9adb5ca5ac3e3c35f65f9dd5a',
secret: 'd594ee86153e106e739c5418b511ff786db627921e9c78a1c92f61f90620e75c',
})
File Functions
You must create an instance of the file class. In this instance is the auth status saved and it refresh on his own.
const file = new fileSystem.File();
Functions
// to get all meta datas from file
response = await file.getData('<FILE_NAME>')
console.log(response);
// to set data to file (like options)
response = await file.setData('<FILE_NAME>', {public: true});
console.log(response);
// upload file
response = await file.createFile('./DIR/<FILE_PATH>');
// upload file with data
response = await file.createFile('./DIR/<FILE_PATH>', {public: true});
console.log(response);
// upload newer version of a file
response = await file.updateFile('<FILE_NAME>', './DIR/<FILE_PATH>');
console.log(response);
// delete file
response = await file.deleteFile('<FILE_NAME>')
console.log(response);
// get file content
response = await file.getFile('<FILE_NAME>')
console.log(response);
// get all uploaded files meta datas
response = await file.getFiles()
console.log(response);