@@ -32,24 +32,24 @@ |
||
32 | 32 | */ |
33 | 33 | class DownloadResponse extends Response { |
34 | 34 | |
35 | - private $filename; |
|
36 | - private $contentType; |
|
37 | - |
|
38 | - /** |
|
39 | - * Creates a response that prompts the user to download the file |
|
40 | - * @param string $filename the name that the downloaded file should have |
|
41 | - * @param string $contentType the mimetype that the downloaded file should have |
|
42 | - * @since 7.0.0 |
|
43 | - */ |
|
44 | - public function __construct($filename, $contentType) { |
|
45 | - parent::__construct(); |
|
46 | - |
|
47 | - $this->filename = $filename; |
|
48 | - $this->contentType = $contentType; |
|
49 | - |
|
50 | - $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
51 | - $this->addHeader('Content-Type', $contentType); |
|
52 | - } |
|
35 | + private $filename; |
|
36 | + private $contentType; |
|
37 | + |
|
38 | + /** |
|
39 | + * Creates a response that prompts the user to download the file |
|
40 | + * @param string $filename the name that the downloaded file should have |
|
41 | + * @param string $contentType the mimetype that the downloaded file should have |
|
42 | + * @since 7.0.0 |
|
43 | + */ |
|
44 | + public function __construct($filename, $contentType) { |
|
45 | + parent::__construct(); |
|
46 | + |
|
47 | + $this->filename = $filename; |
|
48 | + $this->contentType = $contentType; |
|
49 | + |
|
50 | + $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
51 | + $this->addHeader('Content-Type', $contentType); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | 55 | } |
@@ -32,40 +32,40 @@ |
||
32 | 32 | */ |
33 | 33 | class FileDisplayResponse extends Response implements ICallbackResponse { |
34 | 34 | |
35 | - /** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */ |
|
36 | - private $file; |
|
35 | + /** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */ |
|
36 | + private $file; |
|
37 | 37 | |
38 | - /** |
|
39 | - * FileDisplayResponse constructor. |
|
40 | - * |
|
41 | - * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file |
|
42 | - * @param int $statusCode |
|
43 | - * @param array $headers |
|
44 | - * @since 11.0.0 |
|
45 | - */ |
|
46 | - public function __construct($file, $statusCode=Http::STATUS_OK, |
|
47 | - $headers=[]) { |
|
48 | - parent::__construct(); |
|
38 | + /** |
|
39 | + * FileDisplayResponse constructor. |
|
40 | + * |
|
41 | + * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file |
|
42 | + * @param int $statusCode |
|
43 | + * @param array $headers |
|
44 | + * @since 11.0.0 |
|
45 | + */ |
|
46 | + public function __construct($file, $statusCode=Http::STATUS_OK, |
|
47 | + $headers=[]) { |
|
48 | + parent::__construct(); |
|
49 | 49 | |
50 | - $this->file = $file; |
|
51 | - $this->setStatus($statusCode); |
|
52 | - $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
53 | - $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"'); |
|
50 | + $this->file = $file; |
|
51 | + $this->setStatus($statusCode); |
|
52 | + $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
53 | + $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"'); |
|
54 | 54 | |
55 | - $this->setETag($file->getEtag()); |
|
56 | - $lastModified = new \DateTime(); |
|
57 | - $lastModified->setTimestamp($file->getMTime()); |
|
58 | - $this->setLastModified($lastModified); |
|
59 | - } |
|
55 | + $this->setETag($file->getEtag()); |
|
56 | + $lastModified = new \DateTime(); |
|
57 | + $lastModified->setTimestamp($file->getMTime()); |
|
58 | + $this->setLastModified($lastModified); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param IOutput $output |
|
63 | - * @since 11.0.0 |
|
64 | - */ |
|
65 | - public function callback(IOutput $output) { |
|
66 | - if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
67 | - $output->setHeader('Content-Length: ' . $this->file->getSize()); |
|
68 | - $output->setOutput($this->file->getContent()); |
|
69 | - } |
|
70 | - } |
|
61 | + /** |
|
62 | + * @param IOutput $output |
|
63 | + * @since 11.0.0 |
|
64 | + */ |
|
65 | + public function callback(IOutput $output) { |
|
66 | + if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
67 | + $output->setHeader('Content-Length: ' . $this->file->getSize()); |
|
68 | + $output->setOutput($this->file->getContent()); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | * @param array $headers |
44 | 44 | * @since 11.0.0 |
45 | 45 | */ |
46 | - public function __construct($file, $statusCode=Http::STATUS_OK, |
|
47 | - $headers=[]) { |
|
46 | + public function __construct($file, $statusCode = Http::STATUS_OK, |
|
47 | + $headers = []) { |
|
48 | 48 | parent::__construct(); |
49 | 49 | |
50 | 50 | $this->file = $file; |
51 | 51 | $this->setStatus($statusCode); |
52 | 52 | $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
53 | - $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"'); |
|
53 | + $this->addHeader('Content-Disposition', 'inline; filename="'.rawurldecode($file->getName()).'"'); |
|
54 | 54 | |
55 | 55 | $this->setETag($file->getEtag()); |
56 | 56 | $lastModified = new \DateTime(); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function callback(IOutput $output) { |
66 | 66 | if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
67 | - $output->setHeader('Content-Length: ' . $this->file->getSize()); |
|
67 | + $output->setHeader('Content-Length: '.$this->file->getSize()); |
|
68 | 68 | $output->setOutput($this->file->getContent()); |
69 | 69 | } |
70 | 70 | } |