|
@@ 213-218 (lines=6) @@
|
| 210 |
|
$this->cache->set('avatar_upload', file_get_contents($files['tmp_name'][0]), 7200); |
| 211 |
|
$content = $this->cache->get('avatar_upload'); |
| 212 |
|
unlink($files['tmp_name'][0]); |
| 213 |
|
} else { |
| 214 |
|
return new JSONResponse( |
| 215 |
|
['data' => ['message' => $this->l->t('Invalid file provided')]], |
| 216 |
|
Http::STATUS_BAD_REQUEST |
| 217 |
|
); |
| 218 |
|
} |
| 219 |
|
} else { |
| 220 |
|
//Add imgfile |
| 221 |
|
return new JSONResponse( |
|
@@ 219-225 (lines=7) @@
|
| 216 |
|
Http::STATUS_BAD_REQUEST |
| 217 |
|
); |
| 218 |
|
} |
| 219 |
|
} else { |
| 220 |
|
//Add imgfile |
| 221 |
|
return new JSONResponse( |
| 222 |
|
['data' => ['message' => $this->l->t('No image or file provided')]], |
| 223 |
|
Http::STATUS_BAD_REQUEST |
| 224 |
|
); |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
try { |
| 228 |
|
$image = new \OC_Image(); |
|
@@ 246-251 (lines=6) @@
|
| 243 |
|
['data' => 'notsquare'], |
| 244 |
|
Http::STATUS_OK |
| 245 |
|
); |
| 246 |
|
} else { |
| 247 |
|
return new JSONResponse( |
| 248 |
|
['data' => ['message' => $this->l->t('Invalid image')]], |
| 249 |
|
Http::STATUS_OK |
| 250 |
|
); |
| 251 |
|
} |
| 252 |
|
} catch (\Exception $e) { |
| 253 |
|
$this->logger->logException($e, ['app' => 'core']); |
| 254 |
|
return new JSONResponse(['data' => ['message' => $this->l->t('An error occurred. Please contact your admin.')]], Http::STATUS_OK); |
|
@@ 281-286 (lines=6) @@
|
| 278 |
|
*/ |
| 279 |
|
public function getTmpAvatar() { |
| 280 |
|
$tmpAvatar = $this->cache->get('tmpAvatar'); |
| 281 |
|
if (is_null($tmpAvatar)) { |
| 282 |
|
return new JSONResponse(['data' => [ |
| 283 |
|
'message' => $this->l->t("No temporary profile picture available, try again") |
| 284 |
|
]], |
| 285 |
|
Http::STATUS_NOT_FOUND); |
| 286 |
|
} |
| 287 |
|
|
| 288 |
|
$image = new \OC_Image($tmpAvatar); |
| 289 |
|
|
|
@@ 307-310 (lines=4) @@
|
| 304 |
|
* @return JSONResponse |
| 305 |
|
*/ |
| 306 |
|
public function postCroppedAvatar($crop) { |
| 307 |
|
if (is_null($crop)) { |
| 308 |
|
return new JSONResponse(['data' => ['message' => $this->l->t("No crop data provided")]], |
| 309 |
|
Http::STATUS_BAD_REQUEST); |
| 310 |
|
} |
| 311 |
|
|
| 312 |
|
if (!isset($crop['x'], $crop['y'], $crop['w'], $crop['h'])) { |
| 313 |
|
return new JSONResponse(['data' => ['message' => $this->l->t("No valid crop data provided")]], |
|
@@ 318-323 (lines=6) @@
|
| 315 |
|
} |
| 316 |
|
|
| 317 |
|
$tmpAvatar = $this->cache->get('tmpAvatar'); |
| 318 |
|
if (is_null($tmpAvatar)) { |
| 319 |
|
return new JSONResponse(['data' => [ |
| 320 |
|
'message' => $this->l->t("No temporary profile picture available, try again") |
| 321 |
|
]], |
| 322 |
|
Http::STATUS_BAD_REQUEST); |
| 323 |
|
} |
| 324 |
|
|
| 325 |
|
$image = new \OC_Image($tmpAvatar); |
| 326 |
|
$image->crop($crop['x'], $crop['y'], round($crop['w']), round($crop['h'])); |