Skip to content

Commit 0f0e5d3

Browse files
authored
@tus/s3-store: Add support to read files (#500)
1 parent 0143aba commit 0f0e5d3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/s3-store/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,14 @@ export class S3Store extends DataStore {
465465
return upload
466466
}
467467

468+
async read(id: string) {
469+
const data = await this.client.getObject({
470+
Bucket: this.bucket,
471+
Key: id,
472+
})
473+
return data.Body as Readable
474+
}
475+
468476
/**
469477
* Write to the file, starting at the provided offset
470478
*/

packages/server/src/handlers/GetHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class GetHandler extends BaseHandler {
4141
}
4242

4343
// @ts-expect-error exists if supported
44-
const file_stream = this.store.read(id)
44+
const file_stream = await this.store.read(id)
4545
const headers = {'Content-Length': stats.offset}
4646
res.writeHead(200, headers)
4747
return stream.pipeline(file_stream, res, () => {

0 commit comments

Comments
 (0)