Hi

Upload the file directly from the client (browser/mobile) to S3 using presigned URLs.

 const AWS = require('aws-sdk');

const s3 = new AWS.S3();


const getSignedUrl = async (req, res) => {

  const { key, contentType } = req.body;


  const params = {

    Bucket: 'followwork',

    Key: key,

    ContentType: contentType,

    Expires: 60, // URL valid for 60s

  };


  const url = await s3.getSignedUrlPromise('putObject', params);

  res.json({ uploadUrl: url });

};


Previous
Next Post »