Kewego API community forum

Announcement

New API's released

#1 2009-11-01 20:21:25

platypus
New member
Registered: 2009-10-26
Posts: 1

Can't upload file via the "splited" method.

Hi,

I'm trying to upload a video via the following methods:
http://upload.kewego.com/api/uploadFile
http://upload.kewego.com/api/prepareUpload
http://upload.kewego.com/api/finishUpload

But I when I tried the first call I got the following error:
No input file specified

I don't understand why.
This is a piece of my code
  function request($url, $args=array(), $use_app_token=true) {
    $req = curl_init($url);

    $args['APIFormat'] = 'json';
    if ($use_app_token) {
        $args['appToken'] = $this->request(
          'http://api.kewego.com/app/getToken/',
          array('appKey' => Configure::read('kewego.api.key')),
          false
        )->message->appToken;
    }
   
    curl_setopt($req, CURLOPT_HEADER, false);
    curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($req, CURLOPT_POST, true);
    curl_setopt($req, CURLOPT_HTTPHEADER, array('Expect:'));
    // curl_setopt($req, CURLOPT_TIMEOUT, 100);
    curl_setopt($req, CURLOPT_POSTFIELDS, $args);
    if (($response = curl_exec($req)) === false) {
      throw new Exception(curl_error($req));
    }
    curl_close($req);
    echo $response;
    $json_response = json_decode($response)->kewego_response;
   
    // Basic error handling.
    if (property_exists($json_response, 'kewego_error')) {
      echo $response;
      throw new Exception($json_response->kewego_error);
    }
    return $json_response;
  }

  function add_video($video) {
    $video_file = video_tmp_dir.$video;
    if (!file_exists($video_file)) {
      throw new Exception('File '.$video_file.' doesn\'t exists.');
    }
    $upload_file_token = $this->request('http://upload.kewego.com/api/uploadFile/', array('file' => '@'.$video_file))->message->upload_file_token;
    return $upload_file_token;
}

Any idea ?

Offline

 

#2 2009-11-02 10:58:26

dfugeray
Administrator
Registered: 2008-09-05
Posts: 126

Re: Can't upload file via the "splited" method.

Hi,

Did you try to temporaly save your file on the server before sending it to the APIs? It may work like this.

See folowing example : http://developers.kewego.com/kb/?View=e … ntryID=129

The method is not the same but it should work the same way.

Hope it helps,

Regards,

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson