Welcome to the Panopto Community

Please note: All new registrants to the Panopto Community Forum must be approved by a forum moderator or admin. As such, if you navigate to a feature that is members-only, you may receive an error page if your registration has not yet been approved. We apologize for any inconvenience and are approving new members as quickly as possible.

panopto fileupload inquiry

public function getSessionStatus(&$session) {
$this->checkAuth();
$url = '/Panopto/PublicAPI/Rest/sessionUpload/' . $session->sessionData()['ID'];
$response = $this->http->get($url, array(
'headers' => ['Authorization' => 'Bearer ' . $this->token]
));
$this->checkResponseStatus($response, 200);
$response_body = json_decode($response->getBody(), true);
$session = new Session($response_body);
return $response_body['State'];
}
public function finishSession(&$session) {
$this->checkAuth();
$session_data = $session->sessionData();
$session_data['State'] = 1;
$url = '/Panopto/PublicAPI/Rest/sessionUpload/' . $session_data['ID'];
$response = $this->http->put($url, array(
'headers' => ['Authorization' => 'Bearer ' . $this->token],
'json' => $session_data
));
$this->checkResponseStatus($response, 200);
$response_body = json_decode($response->getBody(), true);
$session = new Session($response_body);
}

public function uploadFile($file_path) {
$upload_target = $this->session_data['UploadTarget'];
$file_name = basename($file_path);
$credentials = new Credentials('test', 'test');

$elements = explode('/', $upload_target);
$session_dir = array_pop($elements);
$prefix = array_pop($elements) . '/' . $session_dir;
$bucket = array_pop($elements);
$service_endpoint = implode('/', $elements);
$object_key = $prefix.'/'.$file_name;

$s3Client = new S3Client([
'endpoint' => $service_endpoint,
'region' => 'us-east-2',
'version' => 'latest',
'credentials' => $credentials,
'http' => [
'verify' => false,
],
]);

try {
$source = fopen($file_path, 'rb');

$uploader = new ObjectUploader(
$s3Client,
'Panopto',
$object_key,
$source
);

do {
try {
$result = $uploader->upload();
} catch (MultipartUploadException $e) {
rewind($source);
$uploader = new MultipartUploader($s3Client, $source, [
'state' => $e->getState(),
]);
}
} while (!isset($result));

echo "Upload complete: {$result['ObjectURL']}" . PHP_EOL;
} catch (AwsException $e) {
echo "S3 upload err: " . $e->getMessage() . PHP_EOL;
} }
$client = new Client($host);
$client->authenticate($client_id, $client_secret, $username, $password);
$session = $client->newSession($folder_id);
$session->uploadFile('/home/hostname/video/test.mp4');
$client->finishSession($session);
$status = $client->getSessionStatus($session);
echo $status;

This is a source for uploading files to panopto, but a list is created in the directory, but it does not play.
I think the file wasn't uploaded properly.
If you look at the results, Upload complete is displayed and $status is 1.

What's the problem?

Answers

  • Kevin BaumKevin Baum Panopto Employee

    Hello,

    I'm not able to determine anything from the code provided and would need to investigate this further. Can you please have your POC open a ticket with Panopto Support so I can get some additional information from you to continue investigating this?

    Please let me know if you have any other questions.

    Thanks,

    Kevin

  • If you check the log, it will look like this
    

Sign In or Register to comment.