Configuring & Troubleshooting our Amazon Web Services (AWS) Addon
Covered in this article:
This add-on is available in the Plus and Pro editions of MemberPress.
The MemberPress AWS Add-On will give you the ability to:
- Host private files on Amazon S3
- Provide expiring links to registered members with access to individual files
- Embed Video and Audio files on your WordPress pages & posts using the open source Media Element Player (works in Desktop and Mobile browsers)
- Protect your embedded Audio and Video files from being viewed by non-members
MemberPress AWS can be downloaded from here: MemberPress Add-Ons
What is Amazon AWS?
Amazon Web Services (AWS) is a set of tools provided by Amazon to help people host websites, files and do many other things. Amazon S3 is one of the services offered in Amazon AWS ... it allows you to upload, host and protect files and be backed by the reliability, security and speed of Amazon.com! Amazon AWS is widely used by individuals, fortune 500 companies and every other type of entity in between.
You can sign up for Amazon AWS very easily -- it's pay by usage and quite inexpensive.
Uploading Your Files To Amazon S3
Once you've signed up and are accessing your AWS Management Console you can click on the S3 button here:
Then you'll want to create a "Bucket" ... which is basically like a folder:
Make sure your bucket names only contain *lowercase* letters, numbers and dashes ... and that it starts & ends with a lowercase letter. You can read more about these restrictions on Amazon's AWS developer resource website.
Once your bucket is in place, you can click on it ... from within your bucket you can then upload files, create folders and generally organize your files how ever you want:
Try to make sure that any of your folder names and files only contain uppercase letters, lowercase letters, numbers or dashes ... please try to avoid spaces & special characters in your folder and file names. While this isn't specifically forbidden by Amazon S3's guidelines, special characters (including spaces) have been known to interfere with MemberPress AWS's ability to work properly.
Retrieving Your Amazon Security Credentials
Before you can start using MemberPress AWS you have to enter the Amazon Security credentials associated with your account into your MemberPress website's Options page.
To get your security credentials, go to the upper right hand corner of your AWS management console, click your name and select "Security Credentials":
You might then see this pop-up if you haven't accessed this area before. Choose "Get Started with IAM Users".
Next choose to add a user and enter a username with Access type* selected as "Programmatic access".
Now you'll set permissions for this new user. Under the filter search for "AmazonS3" to bring up the S3 permissions options.
Select the "AmazonS3ReadOnlyAccess" option and click "Next".
Review everything and make sure it looks like the screenshot below. If so, click "Create User".
Lastly you'll need to download the CSV file and keep it safe somewhere.
Now you're ready to paste these two keys into the AWS tab in MemberPress -> Options:
It's IMPORTANT to make sure that your buckets and the files in your buckets are not publicly accessible, as that would defeat any protection of direct access to those files.
Using MemberPress AWS
Now that you've got MemberPress and the MemberPress AWS add-on installed, you can start using the following shortcodes in your pages, posts and custom post types:
A shortcode that displays an expiring url to your protected file:
A shortcode that creates a link to an expiring url to your protected file:
[mepr-s3-link src="coolbucket/anothercoolfile.pdf"]Download My E-Book[/mepr-s3-link]
A shortcode that embeds a protected audio file (using an encoded Media Element Player and expiring urls):
A shortcode that embeds a protected video file (using an encoded Media Element Player and expiring urls):
These options are available for all of the MemberPress AWS shortcodes:
src: This is a way to identify the Amazon S3 bucket and path to the protected Amazon file. These values are formatted "<bucket>/<file path>" -- for example if I had an S3 bucket named 'mycoolzips' and I had a file within that bucket called 'funny.zip' and wanted to create a temporary link or embedded media resource then you'd have an src equal to 'mycoolzips/funny.zip' ...
rule: This identifies the id of the rule that should be used to determine whether or not to display the shortcode.
expires: The time that the amazon link will be valid. This can be any value that would be accepted by PHP's time functions. A good example would be "+5 minutes" for a link that expires within 5 minutes or "+30 seconds" for a link expiring in 30 seconds
target: Set to "new" to open links in a new tab. This option only applies to the mepr-s3-link shortcode.
download: Set to "force" to force the user's browser to download the file when they click the link instead of opening it in the browser. This option only applies to the mepr-s3-url and mepr-s3-link shortcodes.
This shortcode is used to calculate and print out an Amazon S3 expiring link.
This shortcode is used to calculate an Amazon S3 expiring link and display it as the href of a link. This shortcode needs to wrap the text you want displayed for this link.
mepr-s3-audio & mepr-s3-video
These shortcodes are used to embed protected audio and video files onto your pages and posts. Aside from the expire and rule attributes ... and the fact that the src attributes represent file paths for Amazon AWS S3 these shortcodes behave exactly like the audio and video shortcodes built-in to WordPress itself ... including the ability to include fallback video files to maximize compatibility across all browsers.
You can also use any of the shortcode attributes supported by WordPress video shortcodes here: https://codex.wordpress.org/Video_Shortcode
Implementing the shortcodes and their parameters:
As the Using MemberPress AWS section above outlines, you can use mepr-s3-url, mepr-s3-link, mepr-s3-audio & mepr-s3-video for the type of file followed by the src parameter to specify the URL of your file. The following is an example link for a file that uses all of the above parameters so you can see how they can be implemented:
[mepr-s3-link src="coolbucket/anothercoolfile.pdf" rule="123" expires="+10 minutes" target="new" download="force"]Download My E-Book[/mepr-s3-link]
Please remember that the
target="new" option can only be used with the mepr-s3-link shortcode, and that
download="force" can only be used for mepr-s3-url and mepr-s3-link shortcodes
Considerations about Audio and Video
Since the underlying links to audio and video content displayed with these shortcodes are expiring links ... if any file lasts longer than the expiration time there can be issues with users scrubbing video forward or back.
When determining your expire time take these facts into account:
- The shorter the expiration of the links is the more chance there is for issues with the user experience ...
- The longer the expiration of the links is the more chance there is for users to download your video content.
AWS V4 Signatures
Recently Amazon AWS introduced a new way of "signing" expiring urls which they call V4 signatures. The MemberPress AWS add-on now supports V4 signatures. These new signatures are more secure than the original way Amazon has signed expiring urls but are computationally more complex and so we still recommend you stay with the old signature formats if you can. Some newer Amazon AWS regions only support V4 signatures though. If you decide to use V4 signatures you'll need to be prepared to also supply MemberPress AWS with the AWS region that you're using.