-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdl.php
More file actions
29 lines (22 loc) · 744 Bytes
/
dl.php
File metadata and controls
29 lines (22 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
include("config/setup.inc");
include("include/amazon.s3.inc");
$s3 = new S3(SETTINGS_AWS_ACCESS_KEY,SETTINGS_AWS_SECRET_KEY);
$file = $_GET['path'];
parse_url($file);
$path = parse_url($file, PHP_URL_PATH);
$name = basename($path);
$bucket = parse_url($file, PHP_URL_HOST);
$info = $s3->getObject($bucket, $path);
$hd = $info->headers;
$data = $info->body;
$type = $hd['type'];
$size = $hd['size'];
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");
header("Cache-Control: private",false); // required for certain browsers
header('Content-Disposition: attachment; filename="'.$name.'"');
header("Content-Type: $type");
header("Content-Length: ".$size);
echo $data;