Method to force a user to only download via one button
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Please see image https://i.imgur.com/0Fhpsd1.jpg

Is there a way to FORCE the logged_in wordpress user to make him only be able to download my zip file (from Amazon S3) by clicking one grey button?

You don't have to code an entire solution. Just provide tips on methods to do it.

awarded to TheOsch

Crowdsource coding tasks.

1 Solution

Winning solution

Hello!

If i was you I'd make it the following way:

  1. Make the file(s) or an entire bucket non-public.

  2. Create an IAM user and grant him an acces to these file(s).

  3. Write a PHP script containing a function that creates an S3 temporary link (see https://docs.aws.amazon.com/AmazonS3/latest/dev/ShareObjectPreSignedURL.html ) to the file (here is a sample: https://css-tricks.com/snippets/php/generate-expiring-amazon-s3-link/).

  4. Write another script that checks the current WP user, generates a temporary link to the S3 file and "pipes" this file from S3 using the generated link to the output. Here is an useful link describing how it can be done: https://wordpress.stackexchange.com/questions/3480/how-can-i-force-a-file-download-in-the-wordpress-backend , there's a simple way to make a script that produces a file in WP. Also it can be done as a custom page, post etc. - there are many opportunities.

  5. Make the button a link to this script.

By the way, this can be an answer to your previous bounty too.