diff --git a/src/Api/Actions/Users/UploadAvatarAction.php b/src/Api/Actions/Users/UploadAvatarAction.php new file mode 100644 index 000000000..e98ec9ab9 --- /dev/null +++ b/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/src/Api/routes.php b/src/Api/routes.php index 8c413b27b..c1fb00eec 100644 --- a/src/Api/routes.php +++ b/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