This module allows you to easily upload files to an external server using Node.js. The module utilizes Axios, FormData, and fs libraries to perform file uploads.
To use this module, you need to install it via npm.
npm install sazumifile
Here's how to use the module in a Node.js application:
Import the uploadFile module:
const { uploadFile } = require('sazumifile');
Call the uploadFile function with the path to the file you want to upload:
const filePath = 'path/to/your/file.txt';
uploadFile(filePath)
.then((url) => {
console.log(`File uploaded successfully. URL: ${url}`);
})
.catch((error) => {
console.error(`Failed to upload file: ${error.message}`);
});
Make sure to replace 'path/to/your/file.txt' with the actual path to the file you want to upload.