blob: 58c7502a71e1ce1b833a466e7404b1c7b3653582 (
plain)
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
/*
* Copyright 2013 Pierre Schmitz <pierre@archlinux.de>
*
* Licensed under AGPLv3
* (see COPYING for full license text)
*
*/
class Ddownload_nginx extends Ddownload_Driver {
public function serveFile($file, $filename, $type)
{
$CI =& get_instance();
$upload_path = $CI->config->item('upload_path');
$download_location = $CI->config->item('download_nginx_location');
if (strpos($file, $upload_path) === 0) {
$file_path = substr($file, strlen($upload_path));
} else {
throw new \exceptions\ApiException("libraries/ddownload/nginx/invalid-file-path", 'Invalid file path');
}
header('Content-disposition: inline; filename="'.$filename."\"\n");
header('Content-Type: '.$type."\n");
header('X-Accel-Redirect: '.$download_location.$file_path."\n");
}
}
|