Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/Convertio.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,35 @@ public function download($local_fn)

return $this;
}

/**
* Download result file to current Browser (Good for https://ifttt.com/)
*
* @param string $local_fn path to local file to store the result
* @return \Convertio\Convertio
*
* @throws \Exception
* @throws \Convertio\Exceptions\APIException if the Convertio API returns an error
* @throws \Convertio\Exceptions\CURLException if there is a general HTTP / network error
*
*/
public function downloadBrowser($local_fn) {

$this->fetchResultContent();
file_put_contents($local_fn, $this->result_content);

if (file_exists($local_fn)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($local_fn).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($local_fn));
readfile($local_fn);
exit;
}
}

/**
* Update status/progress of the conversion
Expand Down