The next thing we’re going to do is integrate WP eStore with Amazon S3 but you have to start off actually with an Amazon S3 account. I’m going to assume that if you’re watching this that you already have an Amazon account.
Create an Amazon S3 Account
If you don’t, you want to come over here and sign up. You’ll sign up with your regular Amazon account information. I’m currently using the Amazon Simple Storage Service, that’s what Amazon S3 is.
What is an Amazon S3 Bucket?
So we click on that and the first thing really to do here is to go to the AWS Management Console and come over here to your S3 account and create a bucket. Most of these buckets are for all kinds of different stuff so what I’m going to do is just create a new bucket. If you’re starting from scratch, you won’t have all these buckets. A bucket is essentially a filing place.
Create a Bucket
We’re going to say, products and I’m just going to use US Standard as my region so I’ve created a bucket name called products and I’m just going to hit create. Pardon me, it’s byobwebsite.products because the name has to be unique.
Under Permissions, the only permission I’m going to have is granting to me. There isn’t going to be any other permissions set and everything else is there. This essentially means it is restricted, it doesn’t have anything in it.
Upload a Product to a Bucket
For the time being actually, I think what I’m going to do is upload a product. Now, I could create a new folder into this and call it Ebooks and then open up Ebooks and upload some content. It’s going to go to this one here. I’m going to add the file and again, I’m coming back to downloads and How-to-choose-the-right-wordpress-shoppingcart and start the upload. It’s done so now when you select this, you can come over and look at its properties and here is its URL.
Naming Conventions for Buckets and Document Names
Well I got ahead of myself and I was not looking at my notes. So we need to pause and talk about naming conventions. Your bucket names cannot have any spaces in them and probably shouldn’t have any numbers in them. Your bucket name should be all lowercase, letters, no spaces. You can have dashes or underscores but no special characters, no weirdnesses. You can string parts of it together with periods but that’s it and the same thing is true with your document names.
Download Not Working? Check Your Names
Don’t ignore or forget this or you are going to encounter download failure. So if you upload a document to an Amazon S3 bucket and it has spaces or special characters like diacritical marks in it for French or Spanish the download is going to fail. And it’s going to fail because WP eStore chokes on anything that is not a lowercase letter or dash or an underscore.
Notice that the bucket name is byobwebsite/products/ebooks and the document name is this nice standard how-to-choose-the-right-wordpress-shoppingcart-checklist.pdf with every space taken up with the dash, okay? That’s what your names need to look like and the very first thing to consider if your download isn’t working is what have you named your bucket and your file. When you ask for help on the forum, I’m going to ask you, “What is the name of your bucket and your file”, because this is where almost all problems exist, is in improper file naming and bucket naming.
So we’ve uploaded this to our Amazon site and it’s currently set at private. You can see the little lock there, it means it’s private. If you open up Permissions, the only person that has permissions to look at this is me, nobody else has any permissions to look at this and that’s the way you want to keep it.
There are lots of times you may see people showing you how to use Amazon S3 to host and they tell you, you have to make it public. Well, that’s the case in many cases but one of the things that WP eStore does is it provides encrypted security. It will communicate directly with Amazon S3 as if it were you and so it can get information from buckets even though they are private. So you want it to be private.
Set Up the Metadata
There’s one other thing you want to do and that is to set the metadata. Now, if you want it to automatically open up as a PDF when somebody buys it, you don’t have to worry about the metadata. But if you want it to be automatically downloaded when somebody buys a PDF or an audio or a video, then you have to come over here and check “Add more metadata” and then choose the key as Content-Disposition and the value is Attachment.
If you don’t have this set like this and the file is of a file type that the browser recognizes and can open like video file or an audio file or a PDF then it will open it rather than directly downloading it. Some of your potential purchasers will have problems with that so you want to set the Content-Disposition to Attachment, hit save.
There’s no way for you to do this if you’ve stored your files in WordPress. If you use the Media Library to upload your files then when somebody goes to download the product, it will automatically open in their browser as long as it’s a document type that can be opened by a browser. So this is one of the benefits of using Amazon S3 to host products.
Add Amazon S3 URL to WP eStore
Now we want to copy that link address and then come over to our product here and we’re going to edit that product. I guess we have to do that in WP eStore in Manage Products. So here’s our Apple Ardor Product, we edit it and come back over to our Digital Content Details. Now what we can do is put this Amazon S3 URL here instead.
One thing to keep in mind is that because WP eStore communicates with Amazon S3 in a secure way using a different server, we have to change this https and we have to change it to as3tp, that is as3tp, okay? It’s as3tp://s3.amazon such and such. You have to make this change to it in order for it to work properly. Now, we can save our product.
Set WP eStore and Amazon to Communicate
This will not work all by its lonesome because there’s one other thing you have to do and that other is configure the settings so that WP eStore can communicate with Amazon. You do that under Addon Settings. Come over here to this and what you need is your access key and your secret access key.
So if we come back over here to Amazon and to My Account, you can come right down here to Security Credentials. They’re talking about a new system here that lets you limit security credentials to specific places and I’m not going to do that at the moment, I’m going to go ahead and use my access key.
You can see how long I’ve had this, right? I’ve had the same access key since July 12, 2009 and this is the access key. There’s my access key ID and then I’ve got my secret access key that I have to have. In this case we have to do the Legacy Security Credential. You copy the secret access key and place it also here and now, it can work. Update that and now WP eStore can communicate with Amazon S3 and can download that file using that as3tp protocol. So this file here now will be served when the product is done.