s3: fix encoding of downloaded stream
This commit is contained in:
@@ -28,13 +28,14 @@ const assert = require('assert'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
{ ConfiguredRetryStrategy } = require('@smithy/util-retry'),
|
||||
constants = require('../constants.js'),
|
||||
consumers = require('node:stream/consumers'),
|
||||
debug = require('debug')('box:storage/s3'),
|
||||
http = require('http'),
|
||||
https = require('https'),
|
||||
{ NodeHttpHandler } = require('@smithy/node-http-handler'),
|
||||
{ PassThrough } = require('node:stream'),
|
||||
path = require('path'),
|
||||
Readable = require('stream').Readable,
|
||||
{ Readable } = require('stream'),
|
||||
{ S3 } = require('@aws-sdk/client-s3'),
|
||||
safe = require('safetydance'),
|
||||
{ Upload } = require('@aws-sdk/lib-storage');
|
||||
@@ -199,10 +200,10 @@ class S3MultipartDownloadStream extends Readable {
|
||||
if (error) return this._handleError(error);
|
||||
|
||||
const contentLength = parseInt(data.ContentLength, 10); // should be same as length
|
||||
const body = await data.Body.transformToString();
|
||||
|
||||
if (contentLength > 0) {
|
||||
this._readSize += contentLength;
|
||||
const body = await consumers.buffer(data.Body); // data.Body.transformToString('binary') also works
|
||||
this.push(body);
|
||||
} else {
|
||||
this._done();
|
||||
|
||||
Reference in New Issue
Block a user