This article will show you how to use WordPress Amazon S3 Smart Upload plugin to upload files straight to S3 bucket without using local storage.
- Create an S3 bucket & get access key
- Configure S3 bucket under our plugin’s settings page
- Upload files directly to your S3 bucket
- WordPress Amazon S3 Smart Upload version 1.0.0 and greater
Create an S3 bucket & get access key
First of all, you need to create an Amazon S3 bucket storing your media file uploads.
Secondly, generate an access key that gives our plugin permission to access and upload files to this bucket.
Enable CORS on S3 bucket
Due to upload files directly from local instead of website server, you need to enable Cross-Origin Resource Sharing (CORS) on your S3 bucket.
To do so, go to your bucket and select Permission >> CORS Configuration.
Then copy our custom configuration below to the editor page and save it.
<?xml version="1.0" encoding="UTF-8"?> <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <CORSRule> <AllowedOrigin>*</AllowedOrigin> <AllowedMethod>HEAD</AllowedMethod> <AllowedMethod>GET</AllowedMethod> <AllowedMethod>PUT</AllowedMethod> <AllowedMethod>POST</AllowedMethod> <AllowedMethod>DELETE</AllowedMethod> <MaxAgeSeconds>3000</MaxAgeSeconds> <ExposeHeader>ETag</ExposeHeader> <AllowedHeader>*</AllowedHeader> </CORSRule> </CORSConfiguration>
* refers to all external domains. Alternatively, you can specify a particular domain (http://example.com) instead.
Once finished, go back to your WordPress site and configure your S3 bucket.
Configure S3 bucket
After activating our plugin, navigate to the plugin’s settings page under Media >> Upload to S3 menu from your admin dashboard.
You will see the guide to configuring your S3 access keys in wp-config.php file.
Put the following code at the top of your wp-config.php file and replace your AWS keys accordingly.
define('SSU_PROVIDER', 'aws'); define('SSU_KEY', 'your-access-key'); define('SSU_SECRET', 'your-access-secret'); define('SSU_BUCKET', 'your-bucket'); define('SSU_FOLDER', 'your-bucket-folder'); // optional define('SSU_REGION', 'your-bucket-region');
When done, reload this page and start uploading your files.
Upload files to S3 bucket
The left sidebar of this page displays an upload button allowing you to select files to upload from your local.
All files uploaded via our plugin will be private by default. That means no one can access these files directly even though you grant public access to your bucket.
Tick “Show it under media library” if you want to add the upload files to your media library.
Once added, these S3 files can be managed like other WordPress media files. For example, you can select and insert them into content through Add Media while editing any page or post.
The right sidebar shows your S3 bucket folder structure. You can see which files are stored on your S3 bucket as well as copying their S3 URL by simply right-clicking on the files’ title.