8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
That is the code I use as middlewear
I try to access the file size at the: req.file = { name: file.originalname, encoding: file.encoding, type: file.mimetype, bucketFileKey: keyName, };
Multer itself
Router integration
In text form: const multerS3 = require("multer-s3"); const multer = require("multer"); const uuid = require("uuid");
import { S3Client } from "@aws-sdk/client-s3";
const s3 = new S3Client({ region: "eu", credentials: { accessKeyId: process.env.AWS_ACCESS_KEY_ID || "", secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || "", }, endpoint: process.env.AWS_END_POINT, forcePathStyle: true, });
export const upload = multer({ storage: multerS3({ s3: s3, bucket: "user-files", acl: "private", key: function (req: any, file: any, cb: any) { const uniqueFileName = uuid.v4(); const keyName = ${req.user.email}/${uniqueFileName}; req.file = { name: file.originalname, encoding: file.encoding, type: file.mimetype, bucketFileKey: keyName, };
${req.user.email}/${uniqueFileName}
cb(null, keyName); }, metadata: function (req: any, file: any, cb: any) { cb(null, { size: file.size }); },
}), });
I integrate it that way
router.post( "/upload", upload.fields([{ name: "file" }, { name: "folder" }]), postUploadFile );
The text was updated successfully, but these errors were encountered:
Okay the point was, when we accept more than 1 form-data fields, we get the files data that way: So you gotta access it that way req.files.file[0]
Sorry, something went wrong.
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
That is the code I use as middlewear
I try to access the file size at the:
req.file = {
name: file.originalname,
encoding: file.encoding,
type: file.mimetype,
bucketFileKey: keyName,
};
Multer itself


Router integration

In text form:
const multerS3 = require("multer-s3");
const multer = require("multer");
const uuid = require("uuid");
import { S3Client } from "@aws-sdk/client-s3";
const s3 = new S3Client({
region: "eu",
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID || "",
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || "",
},
endpoint: process.env.AWS_END_POINT,
forcePathStyle: true,
});
export const upload = multer({
storage: multerS3({
s3: s3,
bucket: "user-files",
acl: "private",
key: function (req: any, file: any, cb: any) {
const uniqueFileName = uuid.v4();
const keyName =
${req.user.email}/${uniqueFileName}
;req.file = {
name: file.originalname,
encoding: file.encoding,
type: file.mimetype,
bucketFileKey: keyName,
};
}),
});
I integrate it that way
router.post(
"/upload",
upload.fields([{ name: "file" }, { name: "folder" }]),
postUploadFile
);
The text was updated successfully, but these errors were encountered: