From 43e7564f1d85ef49ffc128cc30e3d8f273b242a2 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 25 Mar 2015 14:26:17 +0100 Subject: [PATCH] Add route and action for uploading user avatars. --- .../Api/Actions/Users/UploadAvatarAction.php | 21 +++++++++++++++++++ framework/core/src/Api/routes.php | 5 +++++ 2 files changed, 26 insertions(+) create mode 100644 framework/core/src/Api/Actions/Users/UploadAvatarAction.php diff --git a/framework/core/src/Api/Actions/Users/UploadAvatarAction.php b/framework/core/src/Api/Actions/Users/UploadAvatarAction.php new file mode 100644 index 000000000..e98ec9ab9 --- /dev/null +++ b/framework/core/src/Api/Actions/Users/UploadAvatarAction.php @@ -0,0 +1,21 @@ +file('avatar'); + + $this->dispatch( + new UploadAvatarCommand($userId, $this->actor->getUser(), $file), + $routeParams + ); + + return $this->respondWithoutContent(201); + } +} diff --git a/framework/core/src/Api/routes.php b/framework/core/src/Api/routes.php index 8c413b27b..c1fb00eec 100644 --- a/framework/core/src/Api/routes.php +++ b/framework/core/src/Api/routes.php @@ -59,6 +59,11 @@ Route::group(['prefix' => 'api', 'middleware' => 'Flarum\Api\Middleware\LoginWit 'uses' => $action('Flarum\Api\Actions\Users\DeleteAction') ]); + Route::post('users/{id}/avatar', [ + 'as' => 'flarum.api.users.avatar.upload', + 'uses' => $action('Flarum\Api\Actions\Users\UploadAvatarAction') + ]); + /* |-------------------------------------------------------------------------- | Activity