summaryrefslogtreecommitdiffstats
path: root/core/avatar
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2015-03-12 11:13:12 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2015-08-18 14:48:19 +0200
commit65cf4028cc418eba6ddd2aee124de8626148cb57 (patch)
tree1b1416ef3ffde655a50858ac44390e3d3a0721ae /core/avatar
parentffff156965beaf52a22a024e240bf56a9f8d2b44 (diff)
downloadnextcloud-server-65cf4028cc418eba6ddd2aee124de8626148cb57.tar.gz
nextcloud-server-65cf4028cc418eba6ddd2aee124de8626148cb57.zip
Move avatarcontroller towards Node Api
Diffstat (limited to 'core/avatar')
-rw-r--r--core/avatar/avatarcontroller.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/core/avatar/avatarcontroller.php b/core/avatar/avatarcontroller.php
index 2c4be827738..a0c9ebbd785 100644
--- a/core/avatar/avatarcontroller.php
+++ b/core/avatar/avatarcontroller.php
@@ -34,6 +34,7 @@ use OCP\IL10N;
use OCP\IRequest;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\Files\Folder;
/**
* Class AvatarController
@@ -57,6 +58,9 @@ class AvatarController extends Controller {
/** @var IUserSession */
protected $userSession;
+ /** @var Folder */
+ protected $userFolder;
+
/**
* @param string $appName
* @param IRequest $request
@@ -65,6 +69,7 @@ class AvatarController extends Controller {
* @param IL10N $l10n
* @param IUserManager $userManager
* @param IUserSession $userSession
+ * @param Folder $userFolder
*/
public function __construct($appName,
IRequest $request,
@@ -72,7 +77,8 @@ class AvatarController extends Controller {
\OC\Cache\File $cache,
IL10N $l10n,
IUserManager $userManager,
- IUserSession $userSession) {
+ IUserSession $userSession,
+ Folder $userFolder) {
parent::__construct($appName, $request);
$this->avatarManager = $avatarManager;
@@ -80,6 +86,7 @@ class AvatarController extends Controller {
$this->l = $l10n;
$this->userManager = $userManager;
$this->userSession = $userSession;
+ $this->userFolder = $userFolder;
}
/**
@@ -133,12 +140,12 @@ class AvatarController extends Controller {
if (isset($path)) {
$path = stripslashes($path);
- $view = new \OC\Files\View('/'.$userId.'/files');
- if ($view->filesize($path) > 20*1024*1024) {
+ $node = $this->userFolder->get($path);
+ if ($node->getSize() > 20*1024*1024) {
return new DataResponse(['data' => ['message' => $this->l->t('File is too big')]],
Http::STATUS_BAD_REQUEST);
}
- $fileName = $view->getLocalFile($path);
+ $content = $node->getContent();
} elseif (!is_null($files)) {
if (
$files['error'][0] === 0 &&
@@ -150,8 +157,7 @@ class AvatarController extends Controller {
Http::STATUS_BAD_REQUEST);
}
$this->cache->set('avatar_upload', file_get_contents($files['tmp_name'][0]), 7200);
- $view = new \OC\Files\View('/'.$userId.'/cache');
- $fileName = $view->getLocalFile('avatar_upload');
+ $content = $this->cache->get('avatar_upload');
unlink($files['tmp_name'][0]);
} else {
return new DataResponse(['data' => ['message' => $this->l->t('Invalid file provided')]],
@@ -165,7 +171,7 @@ class AvatarController extends Controller {
try {
$image = new \OC_Image();
- $image->loadFromFile($fileName);
+ $image->loadFromData($content);
$image->fixOrientation();
if ($image->valid()) {