Add content to media: localFilePath cannot be null

I’m trying to use the addContent method of Media Service through the Test Console of my Kaltura CE in order to add a video file to media entry.

I’ve initiated an admin session, and can successfuly create a media entry via the Test Console.

Then, I take the ID of the created media entry, and along with the session, I set the KalturaResource to be KalturaServerFileResource with localFilePath of /tmp/sample.mp4 .

The error I recieve is this:

<xml><result><error><code>PROPERTY_VALIDATION_CANNOT_BE_NULL</code><message>The property "KalturaServerFileResource::localFilePath" cannot be null</message><objectType>KalturaAPIException</objectType><args><item><objectType>KalturaApiExceptionArg</objectType><name>PROP_NAME</name><value>KalturaServerFileResource::localFilePath</value></item></args></error></result><executionTime>0.026979923248291</executionTime></xml>

The log from the server (/opt/kaltura/log/kaltura_api_v3.log) is:

2016-05-09 12:16:28 [0.001858] [xx.xxx.xxx.xxx] [1960359633] [1] [API] [global] DEBUG: >------------------------------------- api_v3 -------------------------------------
2016-05-09 12:16:28 [0.000109] [xx.xxx.xxx.xxx] [1960359633] [2] [API] [global] INFO: API-start pid:27359
2016-05-09 12:16:28 [0.000212] [xx.xxx.xxx.xxx] [1960359633] [3] [API] [KalturaFrontController->run] DEBUG: Params [Array
(
[ks] => YjhkZWMyZjA4NmZlMWZjZjY0YzIwOGJmZWYzMzE2NjljOTUyMTljZXwxMDE7MTAxOzE0NjI4NzQ2NzM7MjsxNDYyNzg4MjczLjY1NjQ7Ozs7
[clientTag] => testme
[service] => media
[action] => addcontent
[entryId] => 0_fezsq9uh
[resource:objectType] => KalturaServerFileResource
[resource:localFilePath] => /tmp/sample.mp4
)
]
2016-05-09 12:16:28 [0.001242] [xx.xxx.xxx.xxx] [1960359633] [4] [API] [KalturaDispatcher->dispatch] DEBUG: Dispatching service [media], action [addcontent], reqIndex [1] with params Array
(
[0] => 0_fezsq9uh
[1] => KalturaServerFileResource Object
(
[localFilePath] => /tmp/sample.mp4
[relatedObjects] =>
)

)

2016-05-09 12:16:28 [0.002551] [xx.xxx.xxx.xxx] [1960359633] [5] [API] [KalturaPDO->__construct] DEBUG: conn took - 0.00038886070251465 seconds to mysql:host=localhost;port=3306;dbname=kaltura;


2016-05-09 12:16:28 [0.000872] [xx.xxx.xxx.xxx] [1960359633] [28] [API] [KalturaObject->validateForUsage] ERR: exception ‘Exception’ with message ‘KalturaServerFileResource-localFilePath error: Current user does not have permission to use property “KalturaServerFileResource::localFilePath”’ in /opt/kaltura/app/infra/log/KalturaLog.php:83

I don’t know if the line ‘user does not have permission to use property…’ is related. Can anyone shed some light on the problem?

Hello,

You can see a PHP example of how to use media->addContent() here:

if this does not help, please share your code and I’ll be happy to review and assist.

Thanks, but before adding through code I’d want to successfuly do it via the Test Console… the errors above are caused via the Test Console, therefore I wonder why it doesn’t work.

The test me console is meant as a reference but is hardly perfect. It is also rather hard for me to help you debug it.
I therefore suggest you create a simple standalone script that does something similar to the above. A script is much easier to debug.

Thanks,

Ok… wrote the script in node.js, same error:

{ code: 'PROPERTY_VALIDATION_CANNOT_BE_NULL',
  message: 'The property "KalturaServerFileResource::localFilePath" cannot be null',
  objectType: 'KalturaAPIException',
  args: { PROP_NAME: 'KalturaServerFileResource::localFilePath' } }

I do not think this problem is related to the test console. Can you give me an example of the path you pass to the KalturaServerFileResource?

I tried to put a video named ‘sample.mp4’ on the kaltura server at /tmp/sample.mp4, and I made sure the ‘localFilePath’ property of the KalturaServerFileResource I pass is this path. I also tried tmp/sample.mp4, but none works.

@KalturaFan ,
Sorry for the confusion, but the log was pretty clearly stating this is due to permission.
For more background: It’s intentionally blocked as we don’t want to allow every user to upload files by specifying paths of files in the server. That could become a security risk if it was allowed.
As such this resource type is only allowed for partner -1 (the system wide admin user).

Can I reference a UNC path in some outside NAS for example?

You can reference any path to which the Kaltura PHP processes have access to.
By PHP processes, I mean both Apache children running the PHP module and our batch daemon, implemented as a PHP code that runs in CLI mode.
The Apache would run either with the ‘apache’ user on RHEL/CentOS or as ‘www-data’ on deb based systems.
The Batch daemon runs as the ‘kaltura’ user.

Can you elaborate more about your specific use case? if you just need to upload entries from the FS using the PHP API, I can point you to many examples that do that. But, as Zohar said, you will not be able to use localFilePath since only the batch partner [ID -1] is allowed to do that.

If you have full control over the server, then you can generate an admin KS for the -1 partner, which will allow to perform this action but I would not recommend it at all. If you share your exact scenario, it will be easier to offer alt solutions.

I have a service which outputs videos to a path on a FS (probably a NAS, could be changed. But it won’t be saved on the same server as the Kaltura CE of course).

I want to programatically add media entry and then link it to the video file with the addContent method. I’m not dealing with profiles yet.

I managed to create entry & use the addContent method, but when providing the path I get the above error.

I don’t want to use Dropfolders since I want to control myself over the process the video undergoes. Therefore I don’t want the automatic processing the Dropfolders do.

Got the following exception when adding media entry (creating session worked):

[API] [KalturaFrontController->getExceptionObject] CRIT: exception 'Exception' with message 'Cannot find conversion profile for partner id [-1]' in /opt/kaltura/app/alpha/apps/kaltura/lib/myPartnerUtils.class.php:688

@KalturaFan - What do you mean by “automatic processing the Dropfolders do”?
DropFolders are merely another ingest point, just like uploadToken or localFilePath… by themselves, they don’t do any special processing.

In your case I’d recommend either:

  1. Use Drop Folders
  2. Make the path you’re saving your files on be SSH accessible, and then use KalturaSshUrlResource to ingest the file.

I highly advise against using the -1 partner unless your code is implemented as a native Kaltura server plugin.