Updated on August 18, 2018
How to use S3Media Linksafe – Lite
Best follow the tabs below in the order of appearance for a smooth process. If you never setup your AWS bucket/distribution before, please read this pdf first: Setup-private-download-aws-console
Install like any other plugin on WordPress:
- Go to Plugins > Add New
- Select Upload
- Click the Browse button and locate the zip you downloaded.
- Click Install Now.
- After installation, click Activate plugin.
After install, you find the link to S3Media LinkSafe Lite on the lefthand pane in your admin panel of WordPress:
This will be used to set the Access keys and default options before you use the Link Wizard in the text editor of your posts/pages.
[tab name='Set the options']
Click the S3Media LinkSafe Lite link in the lefthand pane of your admin panel to set your AWS keys and default settings. Here everything is filled in already, but we show you step by step how to do this:
All fields have a convenient hint button that gives a short explanation how to fill in the field correctly:
In the the first part of the options, you need to fill in the Access keys and Keypairs (the latter only if you plan to download distributions):
Getting the Access Keys
After you sign up for AWS, you must create access keys for the account. You can retrieve the access key ID from the Security Credentials page, but you cannot retrieve the secret access key. If the secret access key is lost or forgotten, you need to create new access keys. Go to the Security Credentials page and sign in:
Use your login and password to login. A new page opens with a popup box:
Select Continue to Security Credentials.
In the Access Keys section, click Create New Access Key:
When you have done that, save the Access Keys by downloading them:
Open the file and go to the window tab that shows the S3Media Stream – options, then paste that key into the S3 Access Key – field as shown below.
Then copy the Secret Key and paste it into the S3 Secret Key – field of the S3Media Stream Options. You recognize the secret key easily since it is much longer then the access key:
You can do the same with the Key Pairs of CloudFront. If you have not signed up yet with CloudFront, sign up here logging it with your existing account and follow the instructions, it is fixed in a minute.
NOTE: You do not need CloudFront if you do not plan to work with download distributions but it is a good idea for an international audience.
Getting the Keypairs
To set the Key Pairs, click on the tab CloudFront Key Pairs and click on Create New Key Pair:
You will be asked to safe the Private Key File:
Download the file to a safe place. Then copy the public key:
and paste it in the CloudFront Key Pair ID field of the S3Media LinkSafe options.
NOTE: Do not download the Public Key. It serves no purpose, just copy the string above that link.
Now, open the private key file. The file typically has a name like this: pk-xxxxxx.pem where xxxxx is the name of the public key. In the file you will see the private key displayed. Now, copy everything you see in the file, including the comments and paste it into the CloudFront Private Keyfile field. It should now look more or less like this:
If you forget to comments, it will not work. Make also sure that there are no spaces after each line.
The default options
To make it easy, we provided a set of default options in case you always want to use the same settings:
The Download distribution/S3 bucket field can have the following options:
Either fill in the original name of the bucket, like mybucket
or a download distribution, like https://dhkhhkhkh.cloudfront.net
You can find the correct names in the AWS console. For a bucket, login to the AWS console:
For the bucket name, click on the S3 Service. There you find a list of your existing buckets:
Copy the name and paste in in the Download distribution/S3 bucket field.
For a download distribution, click on the Cloudfront service:
This will show a list with distributions:
Select the download distribution name in the Domain Name Column and copy it.
Unfortunately, it is not possible to select and copy the full address for some unfathomable reason. So, you need do construct it like this: http://d5djz3p829xdh.cloudfront.net
In your situation, the link will be different, but download distributions names always start with a 'd' while streaming distributions start with an 's'. Do not use a streaming distriubtion. It won't work.
Paste your link in the Download distribution/S3 bucket field. We are done with the AWS console now.
URL expires (in seconds)
Here you set the expiring time for your links. This can be as long and as short as you want. On a page with little content, you can get away with 10 minutes or less (600), but keep in mind that visitors are sometimes distracted, so a time 30 minutes is in most cases better (3600).
If a link is expired before the visitor clicks, he/she gets an access denied error and needs to refresh the page to generate a new link.
NOTE: the expiring time is unrelated to the download time. Once the visitor clicks on a link, the file starts to download and when this is a big file, it will keep downloading even if the link expires in the meantime.
If you want to keep the options stored in the databse when you deactivate the plugin for some reason, leave this option set to Keep data upon deactivation.
This is useful if you happen to have compatibility problems with another plugin and want to deactivate this plugin to check whether it has anytihng to do with it. Afterwards, you can activate it again while keeping all keys and default intact.
When you are ready, click the Save button. Now we can place our first link.
Back to the tabs >>
[tab name='Inserting a link']
Inserting protected links in posts an pages
Create post or open an existing one. place your cursor where you want the protected link to appear. This can be within text or on its own line.
Then click the Download Link button above the text editor:
If you don't see that button, your are probably working with the Gutenberg editor, which is not supported. You can either work with the Classic editor or use write the shortcode yourself, using the examples further down the page. We continue here presuming you have access to this button.
Once you click it, it opens the Link Wizard:
This is where you fill in the hyperlink name. In our example, we set this to Webinar - how to market your product.
On the front end of your site you would get this: Webinar - how to market your product
This is an optional field. When you fill this in, the plugin produces an image as a hyperlink instead of a regular hyperlink. Give here the full path to the image, like: https://mydomain.com/myimage.jpg.
The image can reside on your site, on AWS or any other domain, as long as you have permission to use it. For instance, linking to wp-content/uploads/myimage.jpg from another website won't work because permission is automatically restricted to that domain only.
It is possible to influence image size, border, etc via the css class .s3medialinksafe.
Note: This option may give a strange result if you use within a text block, unless you insert a break.
If you do not know the name of the file anymore, you can look it up in the AWS console by going to the S3 service pane and in the list of buckets, click the bucket that contains your file:
Then you get the list of items in your bucket:
Unfortunately, the copy function in the AWS console does not work on all browsers. You have to click on the file name(1) and then select the Properties(2)button to be able to copy the name in the right hand pane:
Then you get can copy the name from the Properties pane:
Paste this in the Download file field.
NOTE: if you placed files in a folder, the file name must be preceded by the folder name. like this: myfolder/myfile.pdf
It is actually easier to work with a list you in a text document you prepared upfront, or you could download a client application to manage your AWS files instead of using the rather cumbersome AWS console:
For Windows, you can download CloudBerry Explorer and for Mac there is Cyberduck.
Cyberduck exists for Windows also but we recommend CloudBerry Explorer as it is a better choice, alas not available on Mac. Those applications are also better suited to upload files, create folders and buckets.
If you filled this in the default settings already, you can leave this as is or you can override the default if you like.
URL expires (seconds)
Expressed in seconds. If you filled this in the default settings already, you can leave this as is or you can override the default if you like.
Determines how the link behaves. Either in the same window or a new window. It is best to set this to new window for all file types that can be opened in the browser itself, like PDF, images, text files, xml, etc...
When you are done, click Insert Link. The short code is now inserted in the text editor:
The short code generating the download link.
Working with default settings keeps the shortcode nice and short. When you select the short code, you can format it to stand out if you like. Making it bold or give it another color.
And this is how it looks at the front end without any formatting. When the user clicks on it, the file can be downloaded or if it is a file type supported by the browser, open it directly in the browser itself, like a PDF or a JPEG, for example.
Working with the shortcode
The shortcode is quite easy to adapt, therefore after you inserted the first shortcode via the Link Wizard, then use that example to quickly insert a range of links in your pages and posts.
There are 5 attributes when you do not use the default options but override them:
- title (any regular alpha and nummerical characters)
- file (case sensitive name of the file you link to)
- path (bucket or download distribution)
- expireseconds (only nummercial value )
- target (either _blank or _parent)
Although the shortcode shows up here on two lines, do not use new lines or it won't work.
If you filled in all the default options, the shortcode only needs to contains 2 attributes:
NOTE: Sometimes, links to download distributions turn into real links in the editor. In that case select the link and use the break link icon.
You can wrap the shortcode in html tags like h1, h2, h3, etc... or use a div with a class or inline style to influence the look. See the demo site to view a couple of possible options.