예제 #1
0
            }
            return Response::download($path);
        });
    }
    /**
     * View download file
     */
    if (Config::get('xysti.routes.downloads.read')) {
        Route::get(Config::get('xysti.routes.downloads.read') . '/(:any)', function ($request) {
            $downloads = Config::get('downloads');
            if (empty($downloads[$request])) {
                return Xysti::error(404, 'Download ' . $request . ' is not in config');
            }
            $download = $downloads[$request];
            // Run authentication etc on the download
            $before = Xysti::before($download);
            if (!is_null($before)) {
                return $before;
            }
            $path = Config::get('xysti.resources.downloads') . $download['uri'];
            if (!file_exists($path)) {
                return Xysti::error(404, 'Download ' . $request . ' could not be found at ' . $path);
            }
            return Response::make(File::get($path), 200, array('Content-Type' => File::mime(File::extension($path))));
        });
    }
}
// 	Catch all routes
// ------------------------------------------------
/**
 * Handle remaining GET requests