skip to Main Content

I am working on React and Django Rest Framework with AWS. I don’t have Public Access blocked on AWS. I am running short on time as I have to complete my project. I want users who access my website to not be able to right-click and copy the download button link. Because then they can save it and share it.

Any suggestions? I was wondering if I could disable the copy link address for the download button. That would make things much easier for me.

code snippet illustrating how to disable the copy link address for a button

2

Answers


  1. Your best approach here is to generate an expiring link to the S3 object. Give it a short expiration time – a couple of minutes, or even less if you only generate it when the user only clicks the link – and sharing it around thus won’t be all that useful.

    https://docs.aws.amazon.com/AmazonS3/latest/userguide/ShareObjectPreSignedURL.html

    In Python, you can use Boto to do this. https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-presigned-urls.html

    s3_client = boto3.client('s3')
    s3_client.generate_presigned_url('get_object', Params={'Bucket': bucket_name, 'Key': object_name}, ExpiresIn=300)
    
    Login or Signup to reply.
  2. You can disable right click using this

    useEffect(() => {
        document.addEventListener('contextmenu', event => {
        event.preventDefault();
        });
    }, [ ])
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search