Skip to content

Commit

Permalink
Decreasing memory footprint dramatically by implementing file uploadi…
Browse files Browse the repository at this point in the history
…ng via HTTP PUT
  • Loading branch information
Dantist committed Nov 11, 2016
1 parent 2333461 commit 04d7eac
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/Convertio.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,24 @@ public function rawStart($data)
public function start($input_fn, $output_format)
{
$data = array();
$data['input'] = 'base64';
$data['file'] = base64_encode(file_get_contents($input_fn));
$data['filename'] = basename($input_fn);
$data['input'] = 'upload';
$data['outputformat'] = $output_format;

return $this->rawStart($data);
$this->rawStart($data);

if ($this->step == 'error') {
return $this;
}

if (!file_exists($input_fn)) {
throw new \Exception("Failed to open stream. No such file: ".$input_fn);
}

$fp = fopen($input_fn, 'r');
$this->api->put('/convert/' . $this->convert_id . '/' . basename($input_fn), $fp);
fclose($fp);

return $this;
}


Expand Down

0 comments on commit 04d7eac

Please sign in to comment.