@strapi/provider-upload-aws-s3 4.1.0 → 4.1.2

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.
Files changed (2) hide show
  1. package/lib/index.js +29 -23
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -16,31 +16,37 @@ module.exports = {
16
16
  ...config,
17
17
  });
18
18
 
19
- return {
20
- upload(file, customParams = {}) {
21
- return new Promise((resolve, reject) => {
22
- // upload file on S3 bucket
23
- const path = file.path ? `${file.path}/` : '';
24
- S3.upload(
25
- {
26
- Key: `${path}${file.hash}${file.ext}`,
27
- Body: Buffer.from(file.buffer, 'binary'),
28
- ACL: 'public-read',
29
- ContentType: file.mime,
30
- ...customParams,
31
- },
32
- (err, data) => {
33
- if (err) {
34
- return reject(err);
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
- // set the bucket file url
38
- file.url = data.Location;
36
+ // set the bucket file url
37
+ file.url = data.Location;
39
38
 
40
- resolve();
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.2",
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": "d4273d81fbeec230b5734375e43a5f1f1f2a0231"
47
+ "gitHead": "6f72c3805232bc6c4b229aecfb19909b9f68d98d"
48
48
  }