
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
save-file-npm
Advanced tools
With this incredible package, managing file uploads has never been easier! You can now simply use the saveFile() method with your inputs and directory, and watch as it handles all the logic for you. The inputs can be of any type - file-object (image, PDF,
This function allows you to save a file to a specified folder on the server. It accepts various input types including URLs, base64 strings, and file objects.
npm install save-file-npm
saveFile(source, folder, fileName?, req?) Uploads a file from the given source to the specified folder. The fileName parameter is optional and can be used to set a custom name for the uploaded file. The req parameter is also optional and can be used to get the full URL of the uploaded file.
The saveFile function takes in the following parameters:
file: This can be an object, string, or base64 data representing the file you want to save. It is a required parameter.folderName: This is a string representing the name of the folder where the file will be saved. It is a required parameter.fileName (optional): This is an optional parameter that allows you to set a custom file name for the saved file.req (optional): This is an optional parameter that can be used to retrieve the current full file URL if needed.
ExamplesImport the "getColumnSum" function into your component or service by adding the following code:
const saveFile = require('save-file-npm');
const saveFile = require('save-file-npm');
// Upload a file from a URL to a folder
saveFile('https://pbs.twimg.com/profile_images/1410074091965403139/IqExKETZ_400x400.jpg', 'new_dir_1')
.then(result => {
console.log(result);
})
.catch(err => console.log(err));
// Upload a file from a URL to a folder and get the full URL
saveFile('https://pbs.twimg.com/profile_images/1410074091965403139/IqExKETZ_400x400.jpg', 'new_dir_1', null, req)
.then(result => {
console.log(result);
})
.catch(err => console.log(err));
// Upload a file from a base64-encoded string to a folder
saveFile(base64, 'new_dir_1')
.then(result => {
console.log(result);
})
.catch(err => console.log(err));
// Upload a file from a file object to a folder
const fileObject = req.file;
saveFile(fileObject, 'new_dir_1')
.then(result => {
console.log(result);
})
.catch(err => console.log(err));
// Upload a file from a file object to a folder and get the full URL
saveFile(fileObject, 'new_dir_2', null, req)
.then(result => {
console.log(result);
})
.catch(err => console.log(err));
// Upload a file from a URL to a folder with a custom file name and get the full URL
saveFile('https://pbs.twimg.com/profile_images/1410074091965403139/IqExKETZ_400x400.jpg', 'new_dir_2', 'new-logo-name', req)
.then(result => {
console.log(result);
})
.catch(err => console.log(err));
This saveFile function is a simple and effective way to save files to a server using a variety of input types. If you have any questions or issues using this function, please don't hesitate to reach out for support.
FAQs
With this incredible package, managing file uploads has never been easier! You can now simply use the saveFile() method with your inputs and directory, and watch as it handles all the logic for you. The inputs can be of any type - file-object (image, PDF,
We found that save-file-npm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.