1. Home
  2. Developers
  3. Advanced topics
  4. Upload directly to Amazon S3

Upload directly to Amazon S3

Uploading using ftp has been used by some of our customers as an alternative to uploading using the vms.
The main reason for using ftp is uploading multiple files at once.
Now that we’ve transitioned from physical datacenter to the cloud based AWS, another way upload files has presented itself.

This example using fineuploader is mostly based on the documentation available at https://docs.fineuploader.com/.
As a side note, this is just an example and only one way to upload files to S3.
There may be a better way to upload files to S3, and we encourage you to keep your options open.

Example code can be found here fineuploader-example.zip

So let’s get started.

In this example we’re using a macbook pro, so this will probably differ from linux/unix and definately differ for Windows.
To run this code you will need php which is pre-installed on osx.
Please make sure php.ini contains the correct settings: variables_order = “EGPCS” and error_reporting = E_ERROR
These settings will make sure that environment variables can be used in php and errors will not show up in the json that’s returned from the fineuploader endpoint.

If you’re reluctant to install npm and composer on your mac, there’s example code with all of the requirements to start working right away.

The easiest way to install node.js is using homebrew https://brew.sh/.

brew install npm

Let’s install composer https://getcomposer.org/ as well.
Just follow the instructions to install composer here https://getcomposer.org/download/.

Now we can start working on building our application.
My favorite editor is Vim, please replace this command by your editor of choice.

mkdir fineuploader-example
cd fineuploader-example

To install the javascript version of fine-uploader:

echo "{}" > package.json
npm install fine-uploader

Any warnings from npm can be safely ignored.

To install the php backend of fine-uploader:

vim composer.json


  "require": {
    "fineuploader/php-s3-server": "1.1.0"

Install the fineuploader php backend:

./composer.phar install

The next step is to show something basic in your favorite browser.

vim index.php


<!DOCTYPE html>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="node_modules/fine-uploader/s3.fine-uploader/fine-uploader-gallery.min.css" rel="stylesheet">
        <script src="node_modules/fine-uploader/s3.fine-uploader/s3.fine-uploader.min.js""></script>
        <script type="text/template"id="qq-template">
            <div class="qq-uploader-selector qq-uploader qq-gallery" qq-drop-area-text="Drop files here">
                <div class="qq-total-progress-bar-container-selector qq-total-progress-bar-container">
                    <div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-total-progress-bar-selector qq-progress-bar qq-total-progress-bar"></div>
                <div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone>
                    <span class="qq-upload-drop-area-text-selector"></span>
                <div class="qq-upload-button-selector qq-upload-button">
                    <div>Upload a file</div>
            <span class="qq-drop-processing-selector qq-drop-processing">
                <span>Processing dropped files...</span>
                <span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
            <ul class="qq-upload-list-selector qq-upload-list" role="region" aria-live="polite" aria-relevant="additions removals">
                    <span role="status" class="qq-upload-status-text-selector qq-upload-status-text"></span>
                    <div class="qq-progress-bar-container-selector qq-progress-bar-container">
                        <div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-progress-bar-selector qq-progress-bar"></div>
                    <span class="qq-upload-spinner-selector qq-upload-spinner"></span>
                    <div class="qq-thumbnail-wrapper"> <img class="qq-thumbnail-selector" qq-max-size="120" qq-server-scale></div>
                    <button type="button" class="qq-upload-cancel-selector qq-upload-cancel">X</button>
                    <button type="button" class="qq-upload-retry-selector qq-upload-retry">
                        <span class="qq-btn qq-retry-icon" aria-label="Retry"></span> Retry
                    <div class="qq-file-info">
                        <div class="qq-file-name">
                            <span class="qq-upload-file-selector qq-upload-file"></span>
                            <span class="qq-edit-filename-icon-selector qq-btn qq-edit-filename-icon" aria-label="Edit filename"></span>
                        <input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">
                        <span class="qq-upload-size-selector qq-upload-size"></span>
                        <button type="button" class="qq-btn qq-upload-delete-selector qq-upload-delete">
                            <span class="qq-btn qq-delete-icon" aria-label="Delete"></span>
                        <button type="button" class="qq-btn qq-upload-pause-selector qq-upload-pause">
                            <span class="qq-btn qq-pause-icon" aria-label="Pause"></span>
                        <button type="button" class="qq-btn qq-upload-continue-selector qq-upload-continue">
                            <span class="qq-btn qq-continue-icon" aria-label="Continue"></span>
            <dialog class="qq-alert-dialog-selector">
                <div class="qq-dialog-message-selector"></div>
                <div class="qq-dialog-buttons">
                    <button type="button" class="qq-cancel-button-selector">Close</button>
            <dialog class="qq-confirm-dialog-selector">
                <div class="qq-dialog-message-selector"></div>
                <div class="qq-dialog-buttons">
                    <button type="button" class="qq-cancel-button-selector">No</button>
                    <button type="button" class="qq-ok-button-selector">Yes</button>
            <dialog class="qq-prompt-dialog-selector">
                <div class="qq-dialog-message-selector"></div>
                <input type="text">
                <div class="qq-dialog-buttons">
                    <button type="button" class="qq-cancel-button-selector">Cancel</button>
                    <button type="button" class="qq-ok-button-selector">Ok</button>
        <title>Fine Uploader Gallery UI</title>
        <div id="uploader"></div>
        <script type="text/javascript">
            var uploader = new qq.s3.FineUploader({
                element: document.getElementById("uploader"),
                debug: true,
                request: {
                    endpoint: "http://s3-eu-west-1.amazonaws.com/YOUR_BUCKET_NAME",
                    accessKey: "YOUR_PUBLIC_ACCESS_KEY" },
                    objectProperties: {
                        acl: "public-read-write",
                        key: function (id) {
                            var date = new Date();
                            var year = date.getUTCFullYear();
                            var month = date.getMonth() < 10 ? '0' + date.getMonth() : date.getMonth();
                            var day = date.getDay() < 10 ? '0' + date.getDay() : date.getDay(); // In order to process the file it should be placed in the upload "folder" on S3
                            var filename = 'upload/' + '<publication_name>' + '/' + year + '/' + month + '/' + day + '/' + this.getName(id); return filename;
                    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" } 

Important to note is that the upload key should __always__ start with “upload/” otherwise the item will not be uploaded into the vms.
Also good to know is that the request endpoint needs to be http://s3-eu-west-1.amazonaws.com/YOUR_BUCKET_NAME because of the dots (mm.YOUR_BUCKET_NAME.bbvms.com) used in the name.

Create a startup script to start a development server:

vim startServer.sh


php -d variables_order=EGPCS -d error_reporting=E_ERROR -S

Make sure the file is executable:

chmod +x startupServer.sh

Now to run the development server:


Use your favorite browser to go to

This should show the image below:

Now you should be able to upload images to S3.

Add metadata to a file that’s uploaded
To upload the metadata to the VMS we recommend using the VMS Rpc for
php or java.
To be able to add metadata to a file that has been uploaded using fineuploader, we’re using the filename.
Uploading a file with filename test-2313425536.mxf will translate to a sourceid of test-2313425536.mxf.

require_once( 'bootstrap.php' );

$vms = new VMSRpc('https://<PUBLICATION_NAME>.bbvms.com', null, null, $token);

$properties = array('srcid'=>'test-2313425536.mxf,'xml' => '<media-clip title="New mediaclip" status="published" sourceid="test-2313425536.mxf"></media-clip>');
$result = $vms->doAction('mediaclip', 'put', $properties);

print_r( $result );


Updated on September 28, 2020

Was this article helpful?

Related Articles