@strapi/provider-upload-cloudinary 4.0.0-next.6 → 4.0.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/README.md +1 -1
- package/lib/index.js +6 -6
- package/package.json +23 -25
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Your configuration is passed down to the cloudinary configuration. (e.g: `cloudi
|
|
|
6
6
|
|
|
7
7
|
`actionOptions` are passed directly to the upload and delete functions respectively allowing for custom options such as folder, type, etc. You can see the complete list of upload options [here](https://cloudinary.com/documentation/image_upload_api_reference#upload_optional_parameters) and delete options [here](https://cloudinary.com/documentation/image_upload_api_reference#destroy_optional_parameters)
|
|
8
8
|
|
|
9
|
-
See the [using a provider](https://strapi.io/
|
|
9
|
+
See the [using a provider](https://docs.strapi.io/developer-docs/latest/plugins/upload.html#using-a-provider) documentation for information on installing and using a provider. And see the [environment variables](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#environment-variables) for setting and using environment variables in your configs.
|
|
10
10
|
|
|
11
11
|
**Example**
|
|
12
12
|
|
package/lib/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// Public node modules.
|
|
8
8
|
const cloudinary = require('cloudinary').v2;
|
|
9
9
|
const intoStream = require('into-stream');
|
|
10
|
-
const {
|
|
10
|
+
const { PayloadTooLargeError } = require('@strapi/utils').errors;
|
|
11
11
|
|
|
12
12
|
module.exports = {
|
|
13
13
|
init(config) {
|
|
@@ -15,7 +15,7 @@ module.exports = {
|
|
|
15
15
|
|
|
16
16
|
return {
|
|
17
17
|
upload(file, customConfig = {}) {
|
|
18
|
-
return new Promise(
|
|
18
|
+
return new Promise(resolve => {
|
|
19
19
|
const config = {
|
|
20
20
|
resource_type: 'auto',
|
|
21
21
|
public_id: file.hash,
|
|
@@ -30,9 +30,9 @@ module.exports = {
|
|
|
30
30
|
(err, image) => {
|
|
31
31
|
if (err) {
|
|
32
32
|
if (err.message.includes('File size too large')) {
|
|
33
|
-
|
|
33
|
+
throw new PayloadTooLargeError();
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
throw new Error(`Error uploading to cloudinary: ${err.message}`);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
if (image.resource_type === 'video') {
|
|
@@ -67,10 +67,10 @@ module.exports = {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
if (response.result !== 'ok' && response.result !== 'not found') {
|
|
70
|
-
throw
|
|
70
|
+
throw new Error(`Error deleting on cloudinary: ${response.result}`);
|
|
71
71
|
}
|
|
72
72
|
} catch (error) {
|
|
73
|
-
throw
|
|
73
|
+
throw new Error(`Error deleting on cloudinary: ${error.message}`);
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
76
|
};
|
package/package.json
CHANGED
|
@@ -1,53 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/provider-upload-cloudinary",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Cloudinary provider for strapi upload",
|
|
5
|
-
"homepage": "https://strapi.io",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"upload",
|
|
8
7
|
"cloudinary",
|
|
9
8
|
"strapi"
|
|
10
9
|
],
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"main": "./lib",
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"cloudinary": "^1.25.1",
|
|
17
|
-
"into-stream": "^5.1.0"
|
|
18
|
-
},
|
|
19
|
-
"peerDependencies": {
|
|
20
|
-
"@strapi/plugin-upload": "^4.0.0"
|
|
10
|
+
"homepage": "https://strapi.io",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/strapi/strapi/issues"
|
|
21
13
|
},
|
|
22
|
-
"
|
|
23
|
-
"
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git://github.com/strapi/strapi.git"
|
|
24
17
|
},
|
|
18
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
25
19
|
"author": {
|
|
26
|
-
"email": "perret.luca@gmail.com",
|
|
27
20
|
"name": "Luca Perret",
|
|
21
|
+
"email": "perret.luca@gmail.com",
|
|
28
22
|
"url": "https://github.com/lucaperret"
|
|
29
23
|
},
|
|
30
24
|
"maintainers": [
|
|
31
25
|
{
|
|
32
|
-
"name": "Strapi
|
|
26
|
+
"name": "Strapi Solutions SAS",
|
|
33
27
|
"email": "hi@strapi.io",
|
|
34
28
|
"url": "https://strapi.io"
|
|
35
29
|
}
|
|
36
30
|
],
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
"
|
|
31
|
+
"main": "./lib",
|
|
32
|
+
"directories": {
|
|
33
|
+
"lib": "./lib"
|
|
40
34
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
35
|
+
"scripts": {
|
|
36
|
+
"test": "echo \"no tests yet\""
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@strapi/utils": "4.0.0",
|
|
40
|
+
"cloudinary": "^1.25.1",
|
|
41
|
+
"into-stream": "^5.1.0"
|
|
43
42
|
},
|
|
44
43
|
"engines": {
|
|
45
44
|
"node": ">=12.x.x <=16.x.x",
|
|
46
45
|
"npm": ">=6.0.0"
|
|
47
46
|
},
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
"test": "echo \"no tests yet\""
|
|
47
|
+
"strapi": {
|
|
48
|
+
"isProvider": true
|
|
51
49
|
},
|
|
52
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "b181702f0202b2c6d645d42b195a831f25cd0b03"
|
|
53
51
|
}
|