1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @author Christoph Wurst <[email protected]> |
5
|
|
|
* |
6
|
|
|
* ownCloud - Mail |
7
|
|
|
* |
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
10
|
|
|
* as published by the Free Software Foundation. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace OCA\Mail\Controller; |
23
|
|
|
|
24
|
|
|
use OCA\Mail\Service\Attachment\AttachmentStore; |
25
|
|
|
use OCA\Mail\Service\Attachment\UploadedFile; |
26
|
|
|
use OCP\AppFramework\Controller; |
27
|
|
|
use OCP\AppFramework\Http\JSONResponse; |
28
|
|
|
use OCP\IRequest; |
29
|
|
|
|
30
|
|
|
class LocalAttachmentsController extends Controller { |
31
|
|
|
|
32
|
|
|
/** @var AttachmentStore */ |
33
|
|
|
private $store; |
34
|
|
|
|
35
|
|
|
/** @var string */ |
36
|
|
|
private $userId; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param string $appName |
40
|
|
|
* @param IRequest $request |
41
|
|
|
* @param AttachmentStore $store |
42
|
|
|
* @param string $UserId |
43
|
|
|
*/ |
44
|
|
|
public function __construct($appName, IRequest $request, |
45
|
|
|
AttachmentStore $store, $UserId) { |
46
|
|
|
parent::__construct($appName, $request); |
47
|
|
|
$this->store = $store; |
48
|
|
|
$this->userId = $UserId; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @NoAdminRequired |
53
|
|
|
* |
54
|
|
|
* @return JSONResponse |
55
|
|
|
*/ |
56
|
|
|
public function create() { |
57
|
|
|
$file = $this->request->getUploadedFile('attachment'); |
58
|
|
|
$attachment = $this->store->addFile($this->userId, new UploadedFile($file)); |
59
|
|
|
|
60
|
|
|
return $attachment; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
} |
64
|
|
|
|