Skip to content
alsotang edited this page Jul 17, 2016 · 4 revisions

step1. 作为一个授权用户,我可以上传一张图片,并设置照片的名称、多个标签、alt文本

这一步中,我们使用 bootstrap 来方便我们的前端构建工作,使用 bootstrap 完成了一个上传图片的表单。

相关代码在 view/index.ejs 中:

image

image

后台代码 app.js 中,

image

我们先通过 project-4 提供的 /upload 的接口,将图片上传到 cos 去。这时候,我们得到了图片在 mongodb 里面对应的 ObjectId,通过这一 ObjectId,我们通过 /meta 接口,为图片设置标签和alt信息。

Clone this wiki locally