Using Amazon S3 with Sitelok

Amazon S3 is great place to store your downloads for use with Sitelok. It can handle up to 5TB files with fast downloads without using bandwidth, storage or other resources on your server. Amazon provides an easy to use web based console for managing your S3 account so here is a quick getting started guide.

Setting up an S3 account

Setting up an S3 account

1) Signup for an S3 account at  https://aws.amazon.com/s3/.
2) Once you are signed up you can login to the console at  https://console.aws.amazon.com/s3/home
3) Create a bucket to store your files. Click  Create Bucket and enter a unique name using  only lowercase letters. Select the region that is most suitable for you. We recommend that you set your bucket to private access only for security. This way only Linklok can access the files. This is the default setting for new buckets anyway.

Security credential keys

1) Sitelok needs to have an access key id and secret access key for your S3 account so that it can access the bucket. To get those click  Security Credentials click Users in the menu of your AWS account.

2) Click the Add users button and enter a name for the user. There is no need to allow Management console access. Click Next.

3) Click the Set Permissions tab, find AmazonS3Full Access policy and check it. Click Next.

4) You can review your setup and click Create user.

5) Click the user you just created in the User list and then click the Permissions tab.

6) Check the Third-party Service checkbox and also the Confirmation checkbox at the bottom and click Next.

7) Enter a description for the access and click Create access key

8) Click show to display the Secret access key. Copy both keys and keep them safe.

S3 file path

To setup a download path to use S3 we use a special path like this:-

s3|region|accesskeyid|secretaccesskey|bucketname|

Notice this path uses the pipe character | to split the various parts.
s3 This tells Linklok that this is an S3 path 
region The region identifier for your bucket such as us-east-1There is a list of regions at   http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
accesskeyid This is the access key id 
secretaccesskey This is the secret access key provided
bucketname This is the unique bucket name where you have stored the files. S3 requires all buckets to be lowercase only 


Example download location setting

In Sitelok configuration you can make a download location for S3 and name it has required (S3 for example) like this

so that you can then use the siteloklink() function like this on your members pages

<a href="<?php siteloklink('testfile.zip:S3',1); ?>">Download here</a>

See the Sitelok manual for further details about the siteloklink() function. 
When a download link using S3 is clicked Linklok is first called to perform checks on the link as usual. If all is well then it generates a secure S3 download link to the file and redirects the browser. The S3 link generated has a short 5 minute expiry time so if it is captured it will not be of much use to anyone.  

Using folders in S3

If your bucket contains folders then they can be used in the path like this.

s3|region|accesskeyid|secretaccesskey|bucketname|folder/