summaryrefslogtreecommitdiffstats
path: root/core/Controller
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-08-23 21:44:05 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-09-05 15:11:45 +0200
commit6740c627b87157a16c1cce554307dce807a92602 (patch)
tree90de16b0f24dff80ba0affebd9e4db4956afbcab /core/Controller
parent777c3ee3252fa97f1f564e26739f713af09c8c89 (diff)
downloadnextcloud-server-6740c627b87157a16c1cce554307dce807a92602.tar.gz
nextcloud-server-6740c627b87157a16c1cce554307dce807a92602.zip
Move AvatarController over to FileDisplayResponse
Diffstat (limited to 'core/Controller')
-rw-r--r--core/Controller/AvatarController.php11
1 files changed, 3 insertions, 8 deletions
diff --git a/core/Controller/AvatarController.php b/core/Controller/AvatarController.php
index 484b6f524bf..b27d1182225 100644
--- a/core/Controller/AvatarController.php
+++ b/core/Controller/AvatarController.php
@@ -31,6 +31,7 @@ use OC\AppFramework\Utility\TimeFactory;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDisplayResponse;
+use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Files\File;
use OCP\Files\IRootFolder;
@@ -118,7 +119,7 @@ class AvatarController extends Controller {
*
* @param string $userId
* @param int $size
- * @return JSONResponse|DataDisplayResponse
+ * @return JSONResponse|FileDisplayResponse
*/
public function getAvatar($userId, $size) {
if ($size > 2048) {
@@ -129,25 +130,19 @@ class AvatarController extends Controller {
try {
$avatar = $this->avatarManager->getAvatar($userId)->getFile($size);
- $resp = new DataDisplayResponse($avatar->getContent(),
+ $resp = new FileDisplayResponse($avatar,
Http::STATUS_OK,
['Content-Type' => $avatar->getMimeType()]);
- $resp->setETag($avatar->getEtag());
// Let cache this!
$resp->addHeader('Pragma', 'public');
// Cache for 15 minutes
$resp->cacheFor(900);
- // Set last modified
- $lastModified = new \DateTime();
- $lastModified->setTimestamp($avatar->getMTime());
- $resp->setLastModified($lastModified);
$expires = new \DateTime();
$expires->setTimestamp($this->timeFactory->getTime());
$expires->add(new \DateInterval('PT15M'));
$resp->addHeader('Expires', $expires->format(\DateTime::RFC2822));
-
} catch (NotFoundException $e) {
$user = $this->userManager->get($userId);
$resp = new JSONResponse([