
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
@devcodes-sdk/server-upload
Advanced tools
The `@devcodes-sdk/server-upload` provides functionality for handling file uploads, interacting with Amazon S3, and optimizing image files. This document explains how to install and use the provided functions.
The @devcodes-sdk/server-upload provides functionality for handling file uploads, interacting with Amazon S3, and optimizing image files. This document explains how to install and use the provided functions.
Note: This version is still in development and testing (beta). It may contain bugs and is not yet considered production-ready.
Note: If you are encountering an
AccessDeniederror withisPrivateAccess=false, please review your bucket policy to ensure that the bucket is publicly accessible. To enable public access, navigate to the bucket's permissions tab and click on the "Block public access" settings. Then, disable the "Block all public access" option and save the changes.
To install the package, run:
npm i @devcodes-sdk/server-upload
First, import and initialize the UploadAgent with the necessary options:
import UploadAgent from "@devcodes-sdk/server-upload";
const uploadAgent = new UploadAgent({
s3: [
{
bucketName: "your-bucket-name",
accessKey: "",
bucketRegion: "",
secretKey: "",
isPrivateAccess: true, // Note: This setting does not override inline access permissions.
},
],
}).create();
export const {
uploadMiddleware,
uploadFilesFromRequest,
uploadFileToS3,
generatePreSignedUrl,
deleteFileFromS3,
} = uploadAgent;
This middleware handles file uploads with the following features:
["image/png"] restricts uploads to PNG images only.10 * 1024 * 1024 sets a limit of 10 megabytes..single("file"), the uploaded file is accessed via req.file..array("files"), the uploaded files are accessed via req.files.The middleware returns the uploaded file(s) as a buffer, depending on whether a single file or multiple files are uploaded.
app.post(
"/upload",
uploadMiddleware({
allowedMimes: ["image/png"],
maxSize: 10 * 1024 * 1024,
}).single("avatar"),
async (req, res) => {
try {
// if .single("") is used, req.file will contain the file
const file = req.file;
// if .array("") is used, req.files will contain the files
const files = req.files;
} catch (error) {
res.status(400).json({ message: error });
}
}
);
Processes files uploaded via an HTTP request and uploads them to S3.
uploadMiddleware// Note: The folder path must not start or end with '/'app.post('/upload', uploadMiddleware.single('avatar'), async (req, res) => {
try {
const result = await uploadFilesFromRequest({
req,
folder: '/uploads',
isPrivateAccess: true,
bucketName: 'your-bucket-name',
imageOptimization: true
});
res.json(result);
} catch (error) {
res.status(500).send(error.message);
}
});
Uploads a file directly to S3.
// Note: The folder path must not start or end with '/'uploadFileToS3({
file: fileBuffer,
folder: '/uploads',
isPrivateAccess: true,
bucketName: 'your-bucket-name',
imageOptimization: false
}).then(result => {
console.log(result);
}).catch(error => {
console.error(error);
});
Generates a pre-signed URL for accessing a file in S3.
generatePreSignedUrl({
key: '/uploads/b5c9fecc-1dd0-457f-b55d-dba223050b27',
bucketName: 'your-bucket-name',
expiresIn: 60 // URL valid for 60 seconds
}).then(url => {
console.log(url);
}).catch(error => {
console.error(error);
});
Deletes a file from S3.
deleteFileFromS3({
key: '/uploads/b5c9fecc-1dd0-457f-b55d-dba223050b27',
bucketName: 'your-bucket-name'
}).then(result => {
console.log(result);
}).catch(error => {
console.error(error);
});
FAQs
The `@devcodes-sdk/server-upload` provides functionality for handling file uploads, interacting with Amazon S3, and optimizing image files. This document explains how to install and use the provided functions.
We found that @devcodes-sdk/server-upload 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.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.