Skip to content

Commit 5e75809

Browse files
committed
Adds s3 download hotfix
1 parent 86430a3 commit 5e75809

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/services/base/s3-service.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,23 @@ export function downloadFile(credentialBlock: any, isStringData: boolean = true)
6969
return new Observable((subscriber) => {
7070
s3Client.send(new GetObjectCommand(getParams)).then(data => {
7171
const bodyContents = data.Body;
72+
7273
if (isStringData && bodyContents instanceof ReadableStream) {
7374
const reader = bodyContents.getReader();
7475
reader.read().then(({ done, value }) => {
7576
const objectData = new TextDecoder('utf-8').decode(value);
7677
subscriber.next(objectData);
7778
});
7879
} else {
79-
subscriber.next(bodyContents);
80+
//new sdk can return readableStream or blob
81+
if (bodyContents instanceof ReadableStream) {
82+
bodyContents.transformToByteArray().then((data) => {
83+
subscriber.next(new Blob([data]));
84+
})
85+
}
86+
else {
87+
subscriber.next(bodyContents);
88+
}
8089
}
8190
}).catch(err => {
8291
subscriber.error(null);

0 commit comments

Comments
 (0)