$message = $message->withHeader('fOO', 'baz');
if ($file) {
$obj = $storage->download($file);
if (!is_null($obj)) {
$meta = $storage->getInfoFile($file);
ob_get_level() && ob_end_clean();
header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');
header('Content-Type: application/force-download');
header('Content-Description: inline; File Transfer');
header('Content-Transfer-Encoding: binary');
if (array_key_exists('name', $meta) & array_key_exists('size', $meta)) {
header('Content-Disposition: attachment; filename="' . $meta['name'] . '";', false);
header('Content-Length: ' . $meta['size']);
}
$speed = 1024 * $limit;
if ($speed > 0) {
$sleep = 1;
} else {
$speed = 8 * 1024;
$sleep = 0;
}
while (!$obj->eof()) {
$buf = $obj->fread($speed);
print($buf);
if ($sleep) {
sleep(1);
}
flush();
}
exit;
}