View but not download with S3
Hi, I have a subscription service that allows users to view certain PDFs that I store on S3, in my NextJS app is there any way to allow the users to still view the PDF but if they try download it they get like a 403 (forbidden) error. I've found a youtube video that kinda does what I'm looking for (https://www.youtube.com/watch?v=x239gnCxGk0&lc=Ugyakc8uGhSM79WxoXd4AaABAg) but it doesn't work for me and I'm not sure how I'd do that with NextJs.
Thanks
Glen Andrews - Ormond Beach Realtor
YouTube
How to Stop People From Downloading S3 Videos
How to stop people from downloading your Amazon s3 videos, pdf, or audio files.
If you want to download the code visit my website at https://glenandrews.net/amazon-s3-video/
4 Replies
to view a file from the internet, you have to download it. the only way I can think off to get around this is to not let people access the file itself, but rather just a preview
you could make it harder by streaming pieces of it at a time, similar to Netflix. still, this is not an absoulte protection, just a bump in the road if someone is truly dedicated
what if i encrypt the file in s3 and then decrypt it on the client side, since the original file is still encrypted it'll download an encrypted version they cant open which is just as good
or would that not wrok?
if you're sending the encypted file to the client, you need to also send the decryption key to be able to decode + view it. you can't really avoid it
when someone views something like a PDF in their browser, that file may get cached on disk by the browser anyway
We once rendered PDF using pdf.js with options a lot of disabled so people can only view it. And most people won't bother going into source code to find pdf urls but still anyone viewing it has already been downloaded