Upload local file via PHP

Astor's Avatar

Astor

25 Jan, 2012 06:11 PM via web

Hello,

I'm trying to upload a video stored in a server folder (ex "/path/to/video.avi") using the post method of panda class. This is my code:

include('panda.php');
$panda = new Panda(); $res = @$panda->post('/videos.json', array(

            'file' => "/path/to/video.avi",
            'path_format' => "myfolder/:id",
            'profiles' => "Profile1"

));

It seems that nothing happens and video is not sent to panda dashboard.

I tried the same code using "source_url" and a video in a public folder (ex "http://www.mysite.com/folder/video.avi") and works great but I would like to avoid moving all videos to public folder before.

Could you please help me? Thanks in advance.

  1. Support Staff 2 Posted by Jonas Pfenniger on 26 Jan, 2012 10:36 AM

    Jonas Pfenniger's Avatar

    Hi Astor,

    what did the $res variable return to you ?

    Regards,
    Jonas

  2. 3 Posted by Astor on 26 Jan, 2012 06:48 PM

    Astor's Avatar

    Hello,

    I'm getting an error:

    stdClass Object ( [error] => NotAuthorized [message] => Signatures do not match: you should have sent xxxxx , but you sent yyyyyy)

    If I just replace the line 'file' => "/path/to/video.avi" with 'source_url' => "http://www.mysite.com/folder/video.avi" everything works fine. I get a video id as expected in $res and video is processed in dashboard (checked online).

  3. Support Staff 4 Posted by Jonas Pfenniger on 26 Jan, 2012 07:09 PM

    Jonas Pfenniger's Avatar

    My bad,

    are you sure you want to upload the file from the server to pandastream ? Ususally
    people prefer that the client browser uploads directly to pandastream as documented here: http://www.pandastream.com/docs/integrate_with_php#implementing_vid...
    This let us handle the load and you just have to keep track of the video IDs on the PHP side.

    In the event that you want to upload from the server, the issue here is that the PHP doesn't have a facility for that. In the previous example you're sending a string '/path/to/video.avi' and not the actual content of the video. This is why you're getting a signature error.

    Hope that it helps,
    Jonas

  4. 5 Posted by Astor on 26 Jan, 2012 11:36 PM

    Astor's Avatar

    Hi!

    I already have the web client and works great but I need to upload another videos with a batch process so that's why I have to do it via PHP.

    I tried to use file_get_contents method (with FILE_BINARY flag) as value for 'file' parameter but I get the same error.

    Finally I have to move the videos to a public folder and use the 'source_url' parameter. All works fine that way.

    Thanks for help anyway :)

  5. Support Staff 6 Posted by Jonas Pfenniger on 26 Jan, 2012 11:53 PM

    Jonas Pfenniger's Avatar

    Okay great :)

  6. Support Staff 7 Posted by Vivien Schilis on 23 Feb, 2012 03:16 PM

    Vivien Schilis's Avatar

    I have updated the php lib https://github.com/pandastream/panda_client_php
    It now supports multipart upload.

    Give it a try.
    Thanks for the feedback
    Vivien

  7. Vivien Schilis closed this discussion on 23 Feb, 2012 03:16 PM.

Comments are currently closed for this discussion. You can start a new one.