MongoDB, Elasticsearch: Allow downloading binary data

This commit is contained in:
Jakub Vrana 2014-01-15 08:26:47 -08:00
parent 60c8ec61e3
commit bb7331e6a0

View file

@ -3,5 +3,8 @@ $TABLE = $_GET["download"];
$fields = fields($TABLE);
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . friendly_url("$TABLE-" . implode("_", $_GET["where"])) . "." . friendly_url($_GET["field"]));
echo $connection->result("SELECT" . limit(idf_escape($_GET["field"]) . " FROM " . table($TABLE), " WHERE " . where($_GET, $fields), 1));
$select = array(idf_escape($_GET["field"]));
$result = $driver->select($TABLE, $select, array(where($_GET, $fields)), $select);
$row = ($result ? $result->fetch_row() : array());
echo $row[0];
exit; // don't output footer