· 5 years ago · May 18, 2020, 02:26 PM
1 $publication = "adasta";
2 $filename = "test_vid.mp4";
3
4 $awsRegion = "eu-west-1";
5 $awsVersion = "latest";
6 $awsBucket = "mm.$publication.bbvms.com";
7 $awsKeyId = "REDACTED";
8 $awsKeysSecret = "REDACTED";
9
10 /*
11 * Uses the Blue Billywig VMS Rpc package available here https://github.com/bluebillywig/composer-vmsrpc
12 * This package handles authentication with the use of a Blue Billywig API Key to calculate a rpctoken needed for all private actions
13 * If you want to calculate rpctoken yourself see https://github.com/bluebillywig/composer-vmsrpc/blob/master/src/RPC.php#L196
14 * And https://github.com/bluebillywig/composer-vmsrpc/blob/master/src/HOTP.php
15 * We recommend using the VMSRpc package to avoid this.
16 */
17 $host = 'https://' . $publication . '.bbvms.com';
18 $apiKey = '0-API_KEY_SECRET';
19 $vms = new VMSRpc($host, null, null, $apiKey);
20
21 // Create mediaclip
22 $title = "Test clip";
23 $status = "published"; // or draft
24 $description = "This is a upload test clip";
25
26 $properties = array(
27 "srcid" => $filename,
28 "xml" => '<media-clip title="' . $title . '" status="' . $status . '" sourceid="' . $filename . '"><description>' . $description . '</description></media-clip>'
29 );
30 // PUT $publication.bbvms.com/api/mediaclip (requires rpctoken parameter)
31 $mediaclip = $vms->doAction("mediaclip", "put", $properties);
32 var_dump($mediaclip);
33
34 // Upload video
35 $s3 = new Aws\S3\S3Client(array(
36 "region" => $awsRegion,
37 "version" => $awsVersion,
38 "credentials" => array(
39 "key" => $awsKeyId,
40 "secret" => $awsKeysSecret
41 )
42 ));
43
44 //Uses BlueBillywig
45 // GET $publication.bbvms.com/api/awsupload (requires rpctoken)
46 $awsUpload = json_decode($vms->sapi("awsupload", array("mediaclipId=" . $mediaclip['id'])));
47 var_dump($awsUpload);
48 $putResult = $s3->putObject([
49 "ACL" => $awsUpload->acl,
50 "Bucket" => $awsBucket,
51 "Key" => "upload/$publication/$filename",
52 "SourceFile" => $filename
53 ]);
54 var_dump($putResult);
55 // End of script