Hi @luca.guindani,
After giving the code another look, I realised you should use this for the KalturaSshUrlResource::url:
sftp://user@host:/full/path/to/source/file
So, in your case, that would be:
sftp://user@host-dns:/home/user/test.m4v
I’m pretty sure if you’ll do the same from your code it will just work but just in case [and since I had to write this anyhow to test] here is full PHP CLI script [using the php5 client] you can run directly from the Kaltura Server for testing:
<?php
if (count($argv)<5){
echo 'Usage:' .__FILE__ .' <service_url> <partnerid> <secret> <user@host:/path/to/remote/file>'."\n";
exit (1);
}
function upload($client,$uri,$title,$conv_profile=null,$type=null)
{
try{
$entry = new KalturaBaseEntry();
$entry->name = $title;
$entry->tags = 'Example';
$entry->description = 'Example Entry Description';
if (isset($conv_profile)){
$entry->conversionProfileId = $conv_profile;
}
if (!isset($type)){
$type = KalturaEntryType::AUTOMATIC;
}
$resource = new KalturaSshUrlResource();
$resource->url = 'sftp://'.$uri;
$resource->publicKey = file_get_contents('/root/.ssh/id_rsa.pub');
$resource->privateKey = file_get_contents('/root/.ssh/id_rsa');
$result = $client->baseEntry->add($entry);
$result = $client->baseEntry->addContent($result->id, $resource);
$id=$result->id;
return($id);
}catch(exception $e){
throw $e;
}
}
$service_url = $argv[1];
$partnerId=$argv[2];
$secret=$argv[3];
$remote_uri = $argv[4];
$basedir=dirname(__FILE__);
require_once($basedir.'/create_session.php');
$client=generate_ks($service_url,$partnerId,$secret,$type=KalturaSessionType::USER,$userId=null);
$ext=explode(".",$remote_uri);
$id=upload($client,$remote_uri,date ("U",time()).'.'.$ext[1],null,null);
echo "Entry ID is $id\n";
Note that this makes use of /opt/kaltura/bin/create_session.php to generate a client, so just put the above script under /opt/kaltura/bin/ on your Kaltura Server and invoke it with:
# php /opt/kaltura/bin/upload_test.php <service_url> <partnerid> <secret> user@host-dns:/home/user/test.m4v
and it should work.
Note the script already concats ‘sftp://’ to the remote URI so do not pass that in the last arg.
Also, you’ll want to adjust the $resource->publicKey and $resource->privateKey to match your paths, these can be passed as args to the script of course but this was just a POC.