smms
sm.ms 图床上传插件
安装
npm install smms
使用
// es6 // import uploadImg from 'smms';// requireconst uploadImg = ;// file 应为 input[type=file] 拿到的 fileList 中的其中一个文件; // 在 jquery 中使用的例子// html: <input type="file" id="input">const input = ; input;
返回数据说明
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
code | String | success | 上传文件状态。正常情况为 success 。出现错误时为 error |
filename | String | smms.jpg | 上传文件时所用的文件名 |
storename | String | 561cc4e3631b1.png | 上传后的文件名 |
size | Int | 187851 | 文件大小 |
width | Int | 1157 | 图片的宽度 |
height | Int | 680 | 图片的高度 |
hash | String | nLbCw63NheaiJp1 | 随机字符串,用于删除文件 |
delete | String | https://sm.ms/api/delete/nLbCw63NheaiJp1 | 删除上传的图片文件专有链接 |
url | String | https://ooo.0o0.ooo/2015/10/13/561cfc3282a13.png | 图片服务器地址 |
path | String | /2015/10/13/561cfc3282a13.png | 图片的相对地址 |
msg | String | No files were uploaded. | 上传图片出错时将会出现 |
错误列表
Access Denied. |
Upload file count limit. |
Upload file frequency limit. |
Server error. Upload directory isn't writable. |
No files were uploaded. |
File is empty. |
File is too large. |
File has an invalid extension. |
Could not save uploaded file. |
响应示例
- 成功示例
{
"code": "success",
"data": {
width: 1157,
height: 680,
filename: "image_2015-08-26_10-54-48.png",
storename: "56249afa4e48b.png",
size: 69525,
path: "/2015/10/19/56249afa4e48b.png",
hash: "nLbCw63NheaiJp1",
timestamp: 1445239546,
url: "https://ooo.0o0.ooo/2015/10/19/56249afa4e48b.png",
delete: "https://sm.ms/api/delete/nLbCw63NheaiJp1"
}
}
- 失败示例
{
code: "error",
msg: "No files were uploaded."
}
其他 API
- 上传历史
;
- 清除历史上传
;
- 删除指定文件
;
详细文档请移步 https://sm.ms/doc/
感谢
感谢 sm.ms 提供的图床服务。
sm.ms 并不是我的站点。