Monday, 11 November 2019

How to get private S3 Object and send to client?

I currently have an S3 bucket that is set to private. What I'm attempting to do is get the S3 Object:​const s3GetPrivateFile = function(){const options = {Bucket: bucket,Key: '1573151286539-consistency1.png'}s3.getObject(options, function(err, data){if(err){console.log(err);} else {return data;}});}​From there, I want to take the returned file and send to client. The reason for proxying file access is for authentication (only certain users can access certain files).​Now the issue I'm facing is how do I take the file returned from the function above and send it to the client? Do I need to store the file in some sort of temp directory, send to client, and then the delete the temporarily stored file? Or can I just directly take the object returned from 's3GetPrivateFile' and send to client? If so, how would I do this?

Submitted November 11, 2019 at 07:46PM by fishingBakersfield

No comments:

Post a Comment