Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
express-fileforge
Advanced tools
`express-fileforge` is a file upload utility for Express.js that simplifies file handling. It provides a convenient way to save files to the server and manage file storage paths. This package is designed to be easy to use and integrate seamlessly with you
express-fileforge
is a file upload utility for Express.js that simplifies file handling. It provides a convenient way to save files to the server and manage file storage paths. This package is designed to be easy to use and integrate seamlessly with your Express.js applications.
npm install express-fileforge
const express = require('express');
const fileForge = require('express-fileforge');
const path = require('path');
const app = express();
// Your route for file upload
app.post('/upload', async function (req, res) {
try {
// Upload file
let uploadedFile = await fileForge.saveFile(req, path.resolve(__dirname),'myFiles', 'abc.pdf');
res.end(`File uploaded successfully: ${uploadedFile}`);
} catch (error) {
console.error(error);
res.status(500).end('Internal Server Error');
}
});
// Route for file deletion
app.delete('/delete/:fileName', async function (req, res) {
try {
// File name from the URL parameter
const fileName = req.params.fileName;
// Delete the specified file
const isDeleted = await fileForge.deleteFile(path.resolve(__dirname),'myFiles', fileName);
if (isDeleted) {
res.end(`File deleted successfully: ${fileName}`);
} else {
res.status(404).end(`File not found: ${fileName}`);
}
} catch (error) {
console.error(error);
res.status(500).end('Internal Server Error');
}
});
// Start the server
app.listen(5050, function () {
console.log('Server Run Success');
});
async function uploadFile() {
try {
var formdata = new FormData();
formdata.append("files", fileInput.files[0]);
var requestOptions = {
method: 'POST',
body: formdata,
redirect: 'follow',
};
const response = await fetch("http://localhost:5050/uploads", requestOptions);
const result = await response.text();
console.log(result);
} catch (error) {
console.log('error', error);
}
}
// Call the function
uploadFile();
async function uploadFile() {
try {
const formData = new FormData();
formData.append("files", fileInput.files[0]);
const response = await axios.post("http://localhost:5050/uploads", formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
console.log(response.data);
} catch (error) {
console.error('Error:', error);
}
}
// Call the function
uploadFile();
const deleteFile = async () => {
const FileName = "abc.pdf";
const requestOptions = {method: 'DELETE'};
try {
const response = await fetch(`http://localhost:5050/delete/${FileName}`, requestOptions);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const result = await response.text();
console.log(result);
} catch (error) {
console.log('error', error);
}
};
// Call the async function
deleteFile();
const deleteFile = async () => {
const FileName = "abc.pdf";
try {
const response = await axios.delete(`http://localhost:5050/delete/${FileName}`);
console.log(response.data);
} catch (error) {
console.log('error', error.message);
}
};
// Call the async function
deleteFile();
This package is licensed under the MIT License - see the LICENSE file for details.
FAQs
`express-fileforge` is a file upload utility for Express.js that simplifies file handling. It provides a convenient way to save files to the server and manage file storage paths. This package is designed to be easy to use and integrate seamlessly with you
The npm package express-fileforge receives a total of 26 weekly downloads. As such, express-fileforge popularity was classified as not popular.
We found that express-fileforge demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.