0

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:

  1. CMS API POST request to create the video object in Video Cloud (same as for pull-based ingestion)
  2. Dynamic Ingest GET request to get the Brightcove S3 bucket URLs
  3. PUT request to upload the source file to the Brightcove S3 bucket
  4. 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

saavedrajj
  • 63
  • 5
  • 1
    Thanks for the AWS API keys, brb mining some bitcoin. Don't bother editing or deleting your question, the internet already has them. Revoke and re-issue immediately. – Sammitch Jun 19 '17 at 23:42
  • The credentials listed are temporary (they have a session token). You cannot revoke temporary credentials (though they will expire at a predetermined time). Instead, you need to change the permissions associated with the credentials so that all subsequent use of the credentials will fail. See http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_disable-perms.html. – jarmod Jun 20 '17 at 00:44
  • Since the call is to `$this->s3` I suspect no `$` is correct. *nothing happens*. Nothing? That should mean it worked. *I have replaced the bucket s3 URL's with the credentials* Where, in the code? Don't mix the pre-signed URL with multipart, that's for non multipart (as indicated in the linked docs). Please edit your question to clarify *exactly* what code generates *exactly* what result. – Michael - sqlbot Jun 20 '17 at 08:40
  • Hi @sqlbot. Thanks for your reply. What I did was replace the values of the credentials array for the Brightcove S3 bucket urls I got from the previous API Call: – saavedrajj Jun 20 '17 at 10:22
  • I also ran this script from the same folder where is the video to be uploaded. The error message I got is: “Parse error: syntax error, unexpected '=' in /Applications/XAMPP/xamppfiles/htdocs/brightcove/fu-api/upload.php on line 15” And 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. – saavedrajj Jun 20 '17 at 10:23

0 Answers0