@strapi/provider-upload-aws-s3 4.1.0 → 4.1.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +29 -23
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -16,31 +16,37 @@ module.exports = {
|
|
|
16
16
|
...config,
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(err
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
19
|
+
const upload = (file, customParams = {}) =>
|
|
20
|
+
new Promise((resolve, reject) => {
|
|
21
|
+
// upload file on S3 bucket
|
|
22
|
+
const path = file.path ? `${file.path}/` : '';
|
|
23
|
+
S3.upload(
|
|
24
|
+
{
|
|
25
|
+
Key: `${path}${file.hash}${file.ext}`,
|
|
26
|
+
Body: file.stream || Buffer.from(file.buffer, 'binary'),
|
|
27
|
+
ACL: 'public-read',
|
|
28
|
+
ContentType: file.mime,
|
|
29
|
+
...customParams,
|
|
30
|
+
},
|
|
31
|
+
(err, data) => {
|
|
32
|
+
if (err) {
|
|
33
|
+
return reject(err);
|
|
34
|
+
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
// set the bucket file url
|
|
37
|
+
file.url = data.Location;
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
resolve();
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
uploadStream(file, customParams = {}) {
|
|
46
|
+
return upload(file, customParams);
|
|
47
|
+
},
|
|
48
|
+
upload(file, customParams = {}) {
|
|
49
|
+
return upload(file, customParams);
|
|
44
50
|
},
|
|
45
51
|
delete(file, customParams = {}) {
|
|
46
52
|
return new Promise((resolve, reject) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/provider-upload-aws-s3",
|
|
3
|
-
"version": "4.1.0",
|
|
3
|
+
"version": "4.1.1-alpha.0",
|
|
4
4
|
"description": "AWS S3 provider for strapi upload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"upload",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"node": ">=12.22.0 <=16.x.x",
|
|
45
45
|
"npm": ">=6.0.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "bedb04a0cc23719e4eac43e6005fe0fa3d48a9a6"
|
|
48
48
|
}
|