|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @author Lukas Reschke <[email protected]> |
|
5
|
|
|
* @author Thomas Müller <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* Mail |
|
8
|
|
|
* |
|
9
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
11
|
|
|
* as published by the Free Software Foundation. |
|
12
|
|
|
* |
|
13
|
|
|
* This program is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU Affero General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace OCA\Mail\Http; |
|
24
|
|
|
|
|
25
|
|
|
use OCP\AppFramework\Http\DownloadResponse; |
|
26
|
|
|
|
|
27
|
|
|
class AttachmentDownloadResponse extends DownloadResponse { |
|
28
|
|
|
/** @var string */ |
|
29
|
|
|
private $content; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Creates a response that prompts the user to download a file which |
|
33
|
|
|
* contains the passed string |
|
34
|
|
|
* @param string $content the content that should be written into the file |
|
35
|
|
|
* @param string $filename the name that the downloaded file should have |
|
36
|
|
|
* @param string $contentType the mimetype that the downloaded file should have |
|
37
|
|
|
*/ |
|
38
|
2 |
|
public function __construct($content, $filename, $contentType){ |
|
39
|
2 |
|
parent::__construct($filename, $contentType); |
|
40
|
2 |
|
$this->content = $content; |
|
41
|
2 |
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Simply sets the headers and returns the file contents |
|
45
|
|
|
* @return string the file contents |
|
46
|
|
|
*/ |
|
47
|
1 |
|
public function render(){ |
|
48
|
1 |
|
return $this->content; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|