MCPcopy Create free account
hub / github.com/coderwhy/coderhub / saveAvatarInfo

Method saveAvatarInfo

src/controller/file.controller.js:7–21  ·  view source on GitHub ↗
(ctx, next)

Source from the content-addressed store, hash-verified

5
6class FileController {
7 async saveAvatarInfo(ctx, next) {
8 // 1.获取图像相关的信息
9 const { filename, mimetype, size } = ctx.req.file;
10 const { id } = ctx.user;
11
12 // 2.将图像信息数据保存到数据库中
13 const result = await fileService.createAvatar(filename, mimetype, size, id);
14
15 // 3.将图片地址保存到user表中
16 const avatarUrl = `${APP_HOST}:${APP_PORT}/users/${id}/avatar`;
17 await userService.updateAvatarUrlById(avatarUrl, id);
18
19 // 4.返回结果
20 ctx.body = '上传头像成功~';
21 }
22
23 async savePictureInfo(ctx, next) {
24 // 1.获取图像信息

Callers

nothing calls this directly

Calls 2

createAvatarMethod · 0.80
updateAvatarUrlByIdMethod · 0.80

Tested by

no test coverage detected