Skip to content

Commit b4f849a

Browse files
[fix] Fix Blob detection for iOS 8/9 (#69)
1 parent eaee5d5 commit b4f849a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

binary.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
var isArray = require('isarray');
88
var isBuf = require('./is-buffer');
9+
var toString = Object.prototype.toString;
10+
var withNativeBlob = typeof global.Blob === 'function' || toString.call(global.Blob) === '[object BlobConstructor]';
11+
var withNativeFile = typeof global.File === 'function' || toString.call(global.File) === '[object FileConstructor]';
912

1013
/**
1114
* Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder.
@@ -97,8 +100,8 @@ exports.removeBlobs = function(data, callback) {
97100
if (!obj) return obj;
98101

99102
// convert any blob
100-
if ((typeof global.Blob === 'function' && obj instanceof Blob) ||
101-
(typeof global.File === 'function' && obj instanceof File)) {
103+
if ((withNativeBlob && obj instanceof Blob) ||
104+
(withNativeFile && obj instanceof File)) {
102105
pendingBlobs++;
103106

104107
// async filereader

0 commit comments

Comments
 (0)