5.16.2
For this tutorial we are going to use PHP to develop a simple server which will sign requests bound for S3.
If PHP is not your style, then feel free to browse the other server-side examples repository. It's quite important for you to read the Amazon S3 server-side integration instructions before you do any of this, though.
Please read our blog post on Fine Uploader S3 for more information regarding setup of your buckets and IAM users.
We've published an S3 endpoint PHP server for Fine Uploader to Packagist, which means you can easily download it to your project using [composer][composer]!
Follow these simple steps to get a copy of the PHP traditional endpoint using Composer:
curl -sS https://getcomposer.org/installer | php
.php composer.phar install
.An example composer.json file may look like this:
{ "require": { "fineuploader/php-s3-server": "1.1.0" } }
Be sure to update the version with the appropriate version of Fine Uploader's S3 PHP server.
You will need to set 4 environment variables before starting the server. These variables will store your AWS client-side secret key, AWS server-side public key, AWS server-side secret key, and the name of your S3 bucket. You set up your bucket, along with all of your keys, in step 1 above.
To set your environment variables on a Unix or Linux system, you may execute 4 lines, similar to this:
export AWS_CLIENT_SECRET_KEY=fake/client-private-key export AWS_SERVER_PUBLIC_KEY=fake-server-public-key export AWS_SERVER_PRIVATE_KEY=fake/server-private-key export S3_BUCKET_NAME=mybucket
You can easily start up a simple HTTP server using PHP. Run the following command in the root of your web server:
php -S 0.0.0.0:8080
The above command will spawn a server on port 8080.
Ensure all relevant configuration options are pointing to the path of the downloaded S3 signature endpoint server.
For example, if you placed composer.json in the root of your web server, the path to your PHP server will be
/vendor/fineuploader/php-s3-server/endpoint.php
. You'll need to be aware of this endpoint when setting
the request.endpoint
, signature.endpoint
,
and uploadSuccess.endpoint
, and
deleteFile.endpoint
configuration options.
A typical configuration may look like this:
var s3Uploader = new qq.s3.FineUploader({ element: document.getElementById("fineuploader-container"), debug: true, request: { endpoint: "http://mybucket.s3.amazonaws.com", accessKey: "my-client-public-key" }, signature: { endpoint: "/vendor/fineuploader/php-s3-server/endpoint.php" }, uploadSuccess: { endpoint: "/vendor/fineuploader/php-s3-server/endpoint.php?success" }, iframeSupport: { localBlankPagePath: "success.html" }, chunking: { enabled: true, concurrent: { enabled: true } }, resume: { enabled: true }, retry: { enableAuto: true, showButton: true }, deleteFile: { enabled: true, endpoint: "/vendor/fineuploader/php-s3-server/endpoint.php" } });
You're all set! If you do run into any problems you can ask a question on [Stack Overflow under the fine-uploader tag][so]. Server example bugs should be reported in the php-s3-server GitHub repository.