Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
Cómo obtener la URL de la imagen de Aws s3 y almacenarla en mongodb usando la función lambda en nodejs

Necesito una ubicación URL de una imagen de AWS s3 y almacenarla en MongoDB con la función lambda. Sé cómo hacerlo de esta manera simple usando servidores, el código adjunto funciona muy bien, carga la imagen y luego obtiene la URL de la imagen del depósito y la guarda en mongodb. pero quiero hacer esto mismo usando la función lambda. Ayúdenme a codificar esto en la función lambda y guíenme paso a paso, soy totalmente nuevo en este aws lambda

controlador de usuario.js:

 const aws = require("aws-sdk"); const multer = require("multer"); const multerS3 = require("multer-s3"); const User = require("../models/userModel"); const s3 = new aws.S3({ accessKeyId: process.env.S3_ACCESS_KEY, secretAccessKey: process.env.S3_SECRET_ACCESS_KEY, region: process.env.S3_BUCKET_REGION, }); const upload = (bucketName) => multer({ storage: multerS3({ s3, bucket: bucketName, metadata: function (req, file, cb) { cb(null, { fieldName: file.fieldname }); }, key: function (req, file, cb) { cb(null, `image-${Date.now()}.jpeg`); }, }), }); exports.setProfilePic = (req, res, next) => { const uploadSingle = upload("profile-picture-upload-youtube").single( "croppedImage" ); uploadSingle(req, res, async (err) => { if (err) return res.status(400).json({ success: false, message: err.message }); await User.create({ photoUrl: req.file.location }); res.status(200).json({ data: req.file.location }); }); };

`

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!