附件判断增加Blob类型

master
yutent 2023-02-17 11:00:40 +08:00
parent 0735b4452d
commit 7983cb0b16
4 changed files with 13 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@bytedo/fetch", "name": "@bytedo/fetch",
"version": "2.1.1", "version": "2.1.2",
"description": "全新的ajax封装。分2个版本, 一个基于XMLHttpRequest, 一个基于window.fetch", "description": "全新的ajax封装。分2个版本, 一个基于XMLHttpRequest, 一个基于window.fetch",
"main": "dist/index.js", "main": "dist/index.js",
"files": [ "files": [

View File

@ -127,7 +127,10 @@ class _Request {
params = options.body params = options.body
} else { } else {
for (let k in options.body) { for (let k in options.body) {
if (toS.call(options.body[k]) === '[object File]') { if (
toS.call(options.body[k]) === '[object File]' ||
toS.call(options.body[k]) === '[object Blob]'
) {
hasAttach = true hasAttach = true
break break
} }

View File

@ -105,7 +105,7 @@ export const Format = {
} }
v = typeof v === 'function' ? v() : v v = typeof v === 'function' ? v() : v
v = toS.call(v) === '[object File]' ? v : encode(v) v = toS.call(v) === '[object File]' || toS.call(v) === '[object Blob]' ? v : encode(v)
arr.push(encode(k) + '=' + v) arr.push(encode(k) + '=' + v)
} }

View File

@ -104,7 +104,10 @@ class _Request {
} }
} else { } else {
for (let k in options.body) { for (let k in options.body) {
if (toS.call(options.body[k]) === '[object File]') { if (
toS.call(options.body[k]) === '[object File]' ||
toS.call(options.body[k]) === '[object Blob]'
) {
hasAttach = true hasAttach = true
break break
} }