I'm trying to add videos to my Brightcove Video Cloud account using the Source File Upload API for Dynamic Ingest. http://docs.brightcove.com/en/video-cloud/di-api/guides/push-based-ingest.html
As the documentation API requests says there are four API requests involved in push-based ingestion:
- CMS API POST request to create the video object in Video Cloud (same as for pull-based ingestion)
- Dynamic Ingest GET request to get the Brightcove S3 bucket URLs
- PUT request to upload the source file to the Brightcove S3 bucket
- Dynamic Ingest POST request to ingest the source file (same as for pull-based ingestion)
I have reached the step 3 and I got my Brightcove S3 bucket URLs and the documentation recommends to use multipart upload using the AWS SDK and gives the following PHP code
<?php
// AWS SDK (for push ingests)
require 'vendor/aws-autoloader.php';
use Aws\S3\S3Client;
use Aws\S3\MultipartUploader;
use Aws\Exception\MultipartUploadException;
/**
 * get S3 information as described above in this doc
 * the code below assumes it has been decoded as $s3response
 * and that $filePath is the local path to the asset file
 */
s3 = new S3Client([
    'version' => 'latest',
    'region'  => 'us-east-1',
    'credentials' => array(
        'key'    => $s3response->access_key_id,
        'secret' => $s3response->secret_access_key,
        'token'  => $s3response->session_token
    )
]);
$params = array(
    'bucket' => $s3response->s3->bucket,
    'key' => $s3response->s3->object_key
);
$uploader = new MultipartUploader($this->s3, $filePath, $params);
try {
    $uploadResponse = $uploader->upload();
} catch (MultipartUploadException $e) {
    echo $e->getMessage() . "\n";
}
?>
I have replaced the credentials with the Brightcove S3 bucket URLs I got from my previous API call:
Step 2: https://ingest.api.brightcove.com/v1/accounts/{ACCOUNT_ID}/videos/{VIDEO_ID}/upload-urls/{SOURCE_NAME}
Something like this:
'credentials' => array(
    'key'    => ‘dfasdfadsfadfadffas’,
    'secret' => ‘dfasdfadsfadfadffas’,
    'token'  => '‘dfasdfadsfadfadffas’,
)
$params = array(
    'bucket' => ‘dfasdfadsfadfadffas’,
    'key' => ‘dfasdfadsfadfadffas’,
);
and I got the following error:
“Parse error: syntax error, unexpected '=' in /Applications/XAMPP/xamppfiles/htdocs/brightcove/fu-api/upload.php on line 15”
Where the line 15 is: s3 = new S3Client([
I’m not an PHP expert so I’m assuming my issue resides in how I’m sending the S3 buckets urls to the PHP Code.
Any advice?
Cheers
