nexusflow
v4.6.2
Published
Library for uploading and downloading files from Firebase Storage.
Maintainers
Readme
Nexusflow
Nexusflow adalah library Node JS untuk mempermudah upload file menggunakan firebase storage.
Instalasi
Nexusflow membutuhkan Node.js v4+ untuk berjalan.
Install dependencies dan devDependencies dan jalankan server.
$ npm install nexusflowCara Penggunaan
Melakukan configurasi pada file app.js, dan contoh kode untuk mengambil list file di storage.
Development Menggunakan File
const nexusflow = require('nexusflow');
const app = new nexusflow().ConnectionApp({
apiKey: // API KEY,
authDomain: // AUTH DOMAIN,
projectId: // PROJECT ID,
storageBucket: // STORAGE BUCKET,
messagingSenderId: // MESSAGING SENDER ID,
appId: // APP ID,
measurementId: // MEASUREMENT ID,
});
const main = async () => {
try {
const result = await app.getFiles();
console.log(result);
} catch (error) {
console.log("Error: ", error.message);
}
};
main();Get Link Files Path
Mengambil link file berdasarkan path file yang di upload.
const nexusflow = require('nexusflow');
// Connection App
const main = async () => {
try {
const result = await main.getLinkFilesByPath({
path: 'example.txt'
});
console.info(result);
} catch (error) {
console.log("Error: ", error.message);
}
};
main();Get Buffer Files Path
Mengambil buffer file berdasarkan path file yang di upload.
const nexusflow = require('nexusflow');
// Connection App
const main = async () => {
try {
const result = await main.getBufferFileByPath({
path: 'example.txt'
});
console.info(result);
} catch (error) {
console.info(error.message);
}
};
main();Upload File Menggunakan Buffer
Upload file ke dalam firebase menggunakan buffer.
const nexusflow = require('nexusflow');
// Connection App
const main = async () => {
try {
const nameFile = 'example.txt';
const file = await fs.readFileSync(nameFile);
const stat = await fs.statSync(nameFile);
const result = await main.uploadFile({
path: 'example.txt',
file: file,
size: stat.size,
maxSizeMb: 3
});
console.info(result);
} catch (error) {
console.info(error.message);
}
};
main();Update File Berdasarkan Path
Update file berdasarkan path file yang di upload.
const nexusflow = require('nexusflow');
// Connection App
const main = async () => {
try {
const nameFile = 'example.txt';
const file = await fs.readFileSync(nameFile);
const stat = await fs.statSync(nameFile);
const result = await main.updateFile({
path: 'example.txt',
file: file,
size: stat.size,
maxSizeMb: 3,
oldFile: 'file.txt'
});
console.info(result);
} catch (error) {
console.info(error.message);
}
};
main();Delete File Berdasarkan Path
Delete file berdasarkan path file yang di upload.
const nexusflow = require('nexusflow');
// Connection App
const main = async () => {
try {
const result = await main.deleteFile({
nameFile: 'example.txt',
});
console.info(result);
} catch (error) {
console.info(error.message);
}
};
main();Development Menggunakan Media
const nexusflow = require('nexusflow');
const app = new nexusflow().ConnectionApp({
apiKey: // API KEY,
authDomain: // AUTH DOMAIN,
projectId: // PROJECT ID,
storageBucket: // STORAGE BUCKET,
messagingSenderId: // MESSAGING SENDER ID,
appId: // APP ID,
measurementId: // MEASUREMENT ID,
});
const main = async () => {
try {
const result = await app.getMedia();
console.log(result);
} catch (error) {
console.log("Error: ", error.message);
}
};
main();Get Link Media Path
Mengambil link media berdasarkan path media yang di upload.
const nexusflow = require('nexusflow');
// Connection App
const main = async () => {
try {
const result = await main.getLinkMediaByPath({
path: 'example.png'
});
console.info(result);
} catch (error) {
console.log("Error: ", error.message);
}
};
main();Get Buffer Media Path
Mengambil buffer media berdasarkan path media yang di upload.
const nexusflow = require('nexusflow');
// Connection App
const main = async () => {
try {
const result = await main.getBufferMediaByPath({
path: 'example.png'
});
console.info(result);
} catch (error) {
console.info(error.message);
}
};
main();Upload Media Menggunakan Buffer
Upload media ke dalam firebase menggunakan buffer.
const nexusflow = require('nexusflow');
// Connection App
const main = async () => {
try {
const nameFile = 'example.png';
const file = await fs.readFileSync(nameFile);
const stat = await fs.statSync(nameFile);
const result = await main.uploadMedia({
path: 'example.png',
file: file,
size: stat.size,
maxSizeMb: 3
});
console.info(result);
} catch (error) {
console.info(error.message);
}
};
main();Update Media Berdasarkan Path
Update media berdasarkan path media yang di upload.
const nexusflow = require('nexusflow');
// Connection App
const main = async () => {
try {
const nameFile = 'example.png';
const file = await fs.readFileSync(nameFile);
const stat = await fs.statSync(nameFile);
const result = await main.updateMedia({
path: 'example.png',
file: file,
size: stat.size,
maxSizeMb: 3,
oldFile: 'file.png'
});
console.info(result);
} catch (error) {
console.info(error.message);
}
};
main();Delete Media Berdasarkan Path
Delete media berdasarkan path media yang di upload.
const nexusflow = require('nexusflow');
// Connection App
const main = async () => {
try {
const result = await main.deleteMedia({
nameFile: 'example.png',
});
console.info(result);
} catch (error) {
console.info(error.message);
}
};
main();