Skip to content

Commit b3bdd92

Browse files
committed
docs: update docs
1 parent 7bcc4bc commit b3bdd92

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ import { Button } from 'components';
127127
npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
128128
```
129129

130+
## 如何使用七牛上传脚本
131+
132+
`build` 文件中的 `qiniu.example.js` 修改为 `qiniu.js`,并将代码里的 `<Access Key>` `<Secret Key>` `<bucket>` 替换成你的即可。
133+
130134
## 如何添加 Polyfill?
131135

132136
原则上组件库默认不添加 Polyfill,原因是防止组件库的使用者在项目中已经主动添加了 Polyfill,总而使得我们提供的组件库代码将其覆盖或重复打包相同功能的代码。如果你想要添加的话,可以使用以下方法:

build/qiniu.example.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,20 @@ const config = new qiniu.conf.Config();
1616
config.zone = qiniu.zone.Zone_z0;
1717

1818
const formUploader = new qiniu.form_up.FormUploader(config);
19-
const putExtra = new qiniu.form_up.PutExtra();
2019

21-
function upload(localFile, key) {
22-
formUploader.putFile(uploadToken, key, localFile, putExtra, function(respErr,
23-
respBody, respInfo) {
20+
function upload(localFile, key, fileInfo) {
21+
const putExtra = new qiniu.form_up.PutExtra({
22+
mimeType: [fileInfo.mimeType],
23+
});
24+
formUploader.putFile(uploadToken, key, localFile, putExtra, function(
25+
respErr,
26+
respBody,
27+
respInfo,
28+
) {
2429
if (respErr) {
2530
throw respErr;
2631
}
27-
if (respInfo.statusCode == 200) {
32+
if (respInfo.statusCode === 200) {
2833
console.log(respBody);
2934
} else {
3035
console.log(respInfo.statusCode);
@@ -33,4 +38,4 @@ function upload(localFile, key) {
3338
});
3439
}
3540

36-
module.exports = upload;
41+
module.exports = upload;

0 commit comments

Comments
 (0)