Comparing version 2.5.4 to 2.5.5
{ | ||
"name": "qiniu-js", | ||
"jsName": "qiniu", | ||
"version": "2.5.4", | ||
"version": "2.5.5", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "description": "Javascript SDK for Qiniu Resource (Cloud) Storage AP", |
@@ -188,3 +188,3 @@ # Qiniu-JavaScript-SDK | ||
* config.region: 选择上传域名区域;当为 `null` 或 `undefined` 时,自动分析上传域名区域。 | ||
* config.retryCount: 上传自动重试次数(整体重试次数,而不是某个分片的重试次数);默认 3 次(即上传失败后最多重试两次);**目前仅在上传过程中产生 `599` 内部错误时生效**,**但是未来很可能会扩展为支持更多的情况**。 | ||
* config.retryCount: 上传自动重试次数(整体重试次数,而不是某个分片的重试次数);默认 3 次(即上传失败后最多重试两次)。 | ||
* config.concurrentRequestLimit: 分片上传的并发请求量,`number`,默认为3;因为浏览器本身也会限制最大并发量,所以最大并发量与浏览器有关。 | ||
@@ -205,3 +205,3 @@ * config.checkByMD5: 是否开启 MD5 校验,为布尔值;在断点续传时,开启 MD5 校验会将已上传的分片与当前分片进行 MD5 值比对,若不一致,则重传该分片,避免使用错误的分片。读取分片内容并计算 MD5 需要花费一定的时间,因此会稍微增加断点续传时的耗时,默认为 false,不开启。 | ||
* fname: `string`,文件原文件名 | ||
* params: `object`,用来放置自定义变量 | ||
* params: `object`,用来放置自定义变量,自定义变量格式请参考[文档](https://developer.qiniu.com/kodo/manual/1235/vars) | ||
* mimeType: `null || array`,用来限制上传文件类型,为 `null` 时表示不对文件类型限制;限制类型放到数组里: | ||
@@ -208,0 +208,0 @@ `["image/png", "image/jpeg", "image/gif"]` |
@@ -67,8 +67,7 @@ import { | ||
} | ||
if (this.putExtra.mimeType && this.putExtra.mimeType.length) { | ||
if (!isContainFileMimeType(this.file.type, this.putExtra.mimeType)){ | ||
let err = new Error("file type doesn't match with what you specify"); | ||
this.onError(err); | ||
return; | ||
} | ||
if (this.putExtra.mimeType && this.putExtra.mimeType.length | ||
&& !isContainFileMimeType(this.file.type, this.putExtra.mimeType)) { | ||
let err = new Error("file type doesn't match with what you specify"); | ||
this.onError(err); | ||
return; | ||
} | ||
@@ -256,3 +255,3 @@ let upload = getUploadUrl(this.config, this.token).then(res => { | ||
this.uploadUrl, | ||
this.file.size, | ||
this.file, | ||
this.key, | ||
@@ -259,0 +258,0 @@ putExtra |
@@ -83,4 +83,4 @@ import { urlSafeBase64Encode, urlSafeBase64Decode } from "./base64"; | ||
// 构造file上传url | ||
export function createMkFileUrl(url, size, key, putExtra) { | ||
let requestUrl = url + "/mkfile/" + size; | ||
export function createMkFileUrl(url, file, key, putExtra) { | ||
let requestUrl = url + "/mkfile/" + file.size; | ||
if (key != null) { | ||
@@ -90,3 +90,3 @@ requestUrl += "/key/" + urlSafeBase64Encode(key); | ||
if (putExtra.mimeType) { | ||
requestUrl += "/mimeType/" + urlSafeBase64Encode(putExtra.mimeType); | ||
requestUrl += "/mimeType/" + urlSafeBase64Encode(file.type); | ||
} | ||
@@ -269,4 +269,3 @@ let fname = putExtra.fname; | ||
export function isContainFileMimeType(fileType, mimeType){ | ||
export function isContainFileMimeType(fileType, mimeType) { | ||
return mimeType.indexOf(fileType) > -1; | ||
@@ -273,0 +272,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1525301