Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Commit fb95fa7

Browse files
fix: Fixed two bugs.
Now upload method using the correct key. The download method is resolved after the file is saved.
1 parent 8e088f2 commit fb95fa7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class S3Wrapper {
5555
return this.s3
5656
.putObject({
5757
Bucket: this.config.bucket,
58-
Key: options.key,
58+
Key: key,
5959
Body: file,
6060
})
6161
.promise()
@@ -65,7 +65,7 @@ class S3Wrapper {
6565
url: `https://${this.config.bucket}.${this.config.endpoint}/${key}`,
6666
}
6767
} else {
68-
return { key: key }
68+
return { key }
6969
}
7070
})
7171
}
@@ -137,11 +137,11 @@ class S3Wrapper {
137137
})
138138
.then(stream => {
139139
return new Promise((resolve, reject) => {
140-
stream
141-
.on('end', () => {
140+
stream.pipe(
141+
fs.createWriteStream(savePath).on('close', () => {
142142
resolve()
143-
})
144-
.pipe(fs.createWriteStream(savePath))
143+
}),
144+
)
145145
})
146146
})
147147
.catch(e => {

0 commit comments

Comments
 (0)