fix(medusa, medusa-file-*): Protected uploads for file services (#2433)
This commit is contained in:
1 parent
7d77d91a3d
commit
3c5e31c645
11 files changed
+196
-20
No files matched your search
@@ -19,9 +19,19 @@ class S3Service extends AbstractFileService {
|
||||
upload(file) {
|
||||
this.updateAwsConfig()
|
||||
|
||||
return this.uploadFile(file)
|
||||
}
|
||||
|
||||
uploadProtected(file) {
|
||||
this.updateAwsConfig()
|
||||
|
||||
return this.uploadFile(file, { acl: "private" })
|
||||
}
|
||||
|
||||
uploadFile(file, options = { isProtected: false, acl: undefined }) {
|
||||
const s3 = new aws.S3()
|
||||
const params = {
|
||||
ACL: "public-read",
|
||||
ACL: options.acl ?? (options.isProtected ? "private" : "public-read"),
|
||||
Bucket: this.bucket_,
|
||||
Body: fs.createReadStream(file.path),
|
||||
Key: `${file.originalname}`,
|
||||
|
||||
Reference in new issue
Block a user