Completed
Push — master ( c7deb4...314746 )
by Beñat
09:20 queued 06:49
created

DownloadController::gaufretteAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the BenGorFile package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace BenGorFile\FileBundle\Controller;
14
15
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
16
use Symfony\Component\HttpFoundation\BinaryFileResponse;
17
18
/**
19
 * File download controller.
20
 *
21
 * @author Beñat Espiña <[email protected]>
22
 */
23
class DownloadController extends Controller
24
{
25
    /**
26
     * Gets the file of given file name in the Gaufrette filesystem.
27
     *
28
     * @param string $filename          The file name
29
     * @param string $uploadDestination The gaufrette filesystem
30
     *
31
     * @return BinaryFileResponse
32
     */
33
    public function gaufretteAction($filename, $uploadDestination)
34
    {
35
        return new BinaryFileResponse('gaufrette://' . $uploadDestination . '/' . $filename);
36
    }
37
38
    /**
39
     * Gets the file of given file name in the Symfony filesystem.
40
     *
41
     * @param string $filename          The file name
42
     * @param string $uploadDestination The path of file storage
43
     *
44
     * @return BinaryFileResponse
45
     */
46
    public function symfonyAction($filename, $uploadDestination)
47
    {
48
        return new BinaryFileResponse($uploadDestination . '/' . $filename);
49
    }
50
}
51