Browse Source

Fix Blob to Text conversion error

Ben Hsieh 7 years ago
parent
commit
7684d886ce
1 changed files with 2 additions and 1 deletions
  1. 2
    1
      src/index.js

+ 2
- 1
src/index.js View File

@@ -257,6 +257,7 @@ class FetchBlobResponse {
257 257
             Blob.build(this.data, { type : cType + ';BASE64' }).then(resolve)
258 258
           break
259 259
           case 'path':
260
+            console.log('##', 'reading path')
260 261
             polyfill.Blob.build(wrap(this.data), { type : cType }).then(resolve)
261 262
           break
262 263
           default:
@@ -276,7 +277,7 @@ class FetchBlobResponse {
276 277
           return base64.decode(this.data)
277 278
         break
278 279
         case 'path':
279
-          return fs.readFile(this.data, 'utf8')
280
+          return fs.readFile(this.data, 'base64').then((b64) => Promise.resolve(base64.decode(b64)))
280 281
         break
281 282
         default:
282 283
           return this.data