Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

252
Visualizações
accessing properties from javascript object

I have below object.

export const multerOptions = {
    storage: diskStorage({
        destination: multerConfig.dest,
        filename: (_req: any, file: any, cb: any) => {
            /* istanbul ignore next */
            cb(null, `${uuid()}${extname(file.originalname)}`);
        },
    }),
};

when I am printing multerOptions.storage it is returning below.

   diskStorage({
        destination: multerConfig.dest,
        filename: (_req: any, file: any, cb: any) => {
            /* istanbul ignore next */
            cb(null, `${uuid()}${extname(file.originalname)}`);
        },
    }),
.

is there anyway I can access this filename or destination

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This one is for single file upload

 /**
 * Module for geting image from s3 cloud server
 */
exports.upload = multer({
    storage: multerS3({
        s3: s3,
        bucket: function (req, file, cb) {
            const path = process.env.AWS_BUCKET_NAME;
            cb(null, path || 'uploads/');
        },
        acl: 'authenticated-read',
        // acl: 'public-read',
        key: function (req, file, cb) {

            console.log("file========", req);
            // console.log(req.path.split('/')[1]);
            // console.log(path.parse(file.originalname).name.replace(" ", "-"));
            // console.log(Date.now() + path.parse(file.originalname).ext);
            // req.path.split('/')[1] ===== Sub-Folder
            // path.parse(file.originalname).name.replace(" ", "-") + Date.now() + path.parse(file.originalname).ext ===== File name
            cb(null, req.path.split('/')[1]+'/'+path.parse(file.originalname).name.replace(" ", "-") + Date.now() + path.parse(file.originalname).ext);
        }
    })
}).single('file');

For Multiple file upload

/**
 * Module for geting image from s3 cloud server
 */
 exports.uploadmultiple = multer({
    storage: multerS3({
        s3: s3,
        bucket: function (req, file, cb) {
            const path = process.env.AWS_BUCKET_NAME;
            cb(null, path || 'uploads/');
        },
        acl: 'authenticated-read',
        // acl: 'public-read',
        key: function (req, file, cb) {

            console.log(req.path.split('/')[1]);
            console.log(path.parse(file.originalname).name.replace(" ", "-"));
            console.log(Date.now() + path.parse(file.originalname).ext);
            // req.path.split('/')[1] ===== Sub-Folder
            // path.parse(file.originalname).name.replace(" ", "-") + Date.now() + path.parse(file.originalname).ext ===== File name
            cb(null, req.path.split('/')[1]+'/'+path.parse(file.originalname).name.replace(" ", "-") + Date.now() + path.parse(file.originalname).ext);
        }
    })
}).array('files', 2);

You can get more info over HERE

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda