@strapi/provider-upload-cloudinary 5.8.1 → 5.10.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/dist/index.js CHANGED
@@ -1,108 +1,118 @@
1
- "use strict";
2
- const cloudinary = require("cloudinary");
3
- const intoStream = require("into-stream");
4
- const utils = require("@strapi/utils");
5
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
6
- function _interopNamespace(e) {
7
- if (e && e.__esModule) return e;
8
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
1
+ 'use strict';
2
+
3
+ var cloudinary = require('cloudinary');
4
+ var intoStream = require('into-stream');
5
+ var utils = require('@strapi/utils');
6
+
7
+ function _interopNamespaceDefault(e) {
8
+ var n = Object.create(null);
9
9
  if (e) {
10
- for (const k in e) {
11
- if (k !== "default") {
12
- const d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
13
  Object.defineProperty(n, k, d.get ? d : {
14
14
  enumerable: true,
15
- get: () => e[k]
15
+ get: function () { return e[k]; }
16
16
  });
17
17
  }
18
- }
18
+ });
19
19
  }
20
20
  n.default = e;
21
21
  return Object.freeze(n);
22
22
  }
23
- const intoStream__default = /* @__PURE__ */ _interopDefault(intoStream);
24
- const utils__namespace = /* @__PURE__ */ _interopNamespace(utils);
25
- const index = {
26
- init(options) {
27
- cloudinary.v2.config(options);
28
- const upload = (file, customConfig = {}) => {
29
- return new Promise((resolve, reject) => {
30
- const config = {
31
- resource_type: "auto",
32
- public_id: file.hash
23
+
24
+ var utils__namespace = /*#__PURE__*/_interopNamespaceDefault(utils);
25
+
26
+ var index = {
27
+ init (options) {
28
+ cloudinary.v2.config(options);
29
+ const upload = (file, customConfig = {})=>{
30
+ return new Promise((resolve, reject)=>{
31
+ const config = {
32
+ resource_type: 'auto',
33
+ public_id: file.hash
34
+ };
35
+ if (file.ext) {
36
+ config.filename = `${file.hash}${file.ext}`;
37
+ }
38
+ if (file.path) {
39
+ config.folder = file.path;
40
+ }
41
+ // For files smaller than 99 MB use regular upload as it tends to be faster
42
+ // and fallback to chunked upload for larger files as that's required by Cloudinary.
43
+ // https://support.cloudinary.com/hc/en-us/community/posts/360009586100-Upload-movie-video-with-large-size?page=1#community_comment_360002140099
44
+ // The Cloudinary's max limit for regular upload is actually 100 MB but add some headroom
45
+ // for size counting shenanigans. (Strapi provides the size in kilobytes rounded to two decimal places here).
46
+ const uploadMethod = file.size && file.size < 1000 * 99 ? cloudinary.v2.uploader.upload_stream : cloudinary.v2.uploader.upload_chunked_stream;
47
+ const uploadStream = uploadMethod({
48
+ ...config,
49
+ ...customConfig
50
+ }, (err, image)=>{
51
+ if (err) {
52
+ if (err.message.includes('File size too large')) {
53
+ reject(new utils__namespace.errors.PayloadTooLargeError());
54
+ } else {
55
+ reject(new Error(`Error uploading to cloudinary: ${err.message}`));
56
+ }
57
+ return;
58
+ }
59
+ if (!image) {
60
+ return;
61
+ }
62
+ if (image.resource_type === 'video') {
63
+ file.previewUrl = cloudinary.v2.url(`${image.public_id}.gif`, {
64
+ video_sampling: 6,
65
+ delay: 200,
66
+ width: 250,
67
+ crop: 'scale',
68
+ resource_type: 'video'
69
+ });
70
+ }
71
+ file.url = image.secure_url;
72
+ file.provider_metadata = {
73
+ public_id: image.public_id,
74
+ resource_type: image.resource_type
75
+ };
76
+ resolve();
77
+ });
78
+ if (file.stream) {
79
+ file.stream.pipe(uploadStream);
80
+ } else if (file.buffer) {
81
+ intoStream(file.buffer).pipe(uploadStream);
82
+ } else {
83
+ throw new Error('Missing file stream or buffer');
84
+ }
85
+ });
33
86
  };
34
- if (file.ext) {
35
- config.filename = `${file.hash}${file.ext}`;
36
- }
37
- if (file.path) {
38
- config.folder = file.path;
39
- }
40
- const uploadMethod = file.size && file.size < 1e3 * 99 ? cloudinary.v2.uploader.upload_stream : cloudinary.v2.uploader.upload_chunked_stream;
41
- const uploadStream = uploadMethod({ ...config, ...customConfig }, (err, image) => {
42
- if (err) {
43
- if (err.message.includes("File size too large")) {
44
- reject(new utils__namespace.errors.PayloadTooLargeError());
45
- } else {
46
- reject(new Error(`Error uploading to cloudinary: ${err.message}`));
87
+ return {
88
+ uploadStream (file, customConfig = {}) {
89
+ return upload(file, customConfig);
90
+ },
91
+ upload (file, customConfig = {}) {
92
+ return upload(file, customConfig);
93
+ },
94
+ async delete (file, customConfig = {}) {
95
+ try {
96
+ const { resource_type: resourceType, public_id: publicId } = file.provider_metadata ?? {};
97
+ const deleteConfig = {
98
+ resource_type: resourceType || 'image',
99
+ invalidate: true,
100
+ ...customConfig
101
+ };
102
+ const response = await cloudinary.v2.uploader.destroy(`${publicId}`, deleteConfig);
103
+ if (response.result !== 'ok' && response.result !== 'not found') {
104
+ throw new Error(response.result);
105
+ }
106
+ } catch (error) {
107
+ if (error instanceof Error) {
108
+ throw new Error(`Error deleting on cloudinary: ${error.message}`);
109
+ }
110
+ throw error;
111
+ }
47
112
  }
48
- return;
49
- }
50
- if (!image) {
51
- return;
52
- }
53
- if (image.resource_type === "video") {
54
- file.previewUrl = cloudinary.v2.url(`${image.public_id}.gif`, {
55
- video_sampling: 6,
56
- delay: 200,
57
- width: 250,
58
- crop: "scale",
59
- resource_type: "video"
60
- });
61
- }
62
- file.url = image.secure_url;
63
- file.provider_metadata = {
64
- public_id: image.public_id,
65
- resource_type: image.resource_type
66
- };
67
- resolve();
68
- });
69
- if (file.stream) {
70
- file.stream.pipe(uploadStream);
71
- } else if (file.buffer) {
72
- intoStream__default.default(file.buffer).pipe(uploadStream);
73
- } else {
74
- throw new Error("Missing file stream or buffer");
75
- }
76
- });
77
- };
78
- return {
79
- uploadStream(file, customConfig = {}) {
80
- return upload(file, customConfig);
81
- },
82
- upload(file, customConfig = {}) {
83
- return upload(file, customConfig);
84
- },
85
- async delete(file, customConfig = {}) {
86
- try {
87
- const { resource_type: resourceType, public_id: publicId } = file.provider_metadata ?? {};
88
- const deleteConfig = {
89
- resource_type: resourceType || "image",
90
- invalidate: true,
91
- ...customConfig
92
- };
93
- const response = await cloudinary.v2.uploader.destroy(`${publicId}`, deleteConfig);
94
- if (response.result !== "ok" && response.result !== "not found") {
95
- throw new Error(response.result);
96
- }
97
- } catch (error) {
98
- if (error instanceof Error) {
99
- throw new Error(`Error deleting on cloudinary: ${error.message}`);
100
- }
101
- throw error;
102
- }
103
- }
104
- };
105
- }
113
+ };
114
+ }
106
115
  };
116
+
107
117
  module.exports = index;
108
118
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { ReadStream } from 'node:fs';\nimport { v2 as cloudinary, ConfigOptions, UploadApiOptions } from 'cloudinary';\nimport intoStream from 'into-stream';\nimport * as utils from '@strapi/utils';\n\ninterface File {\n name: string;\n alternativeText?: string;\n caption?: string;\n width?: number;\n height?: number;\n formats?: Record<string, unknown>;\n hash: string;\n ext?: string;\n mime: string;\n size: number;\n sizeInBytes: number;\n url: string;\n previewUrl?: string;\n path?: string;\n provider?: string;\n provider_metadata?: Record<string, unknown>;\n stream?: ReadStream;\n buffer?: Buffer;\n}\n\nexport default {\n init(options: ConfigOptions) {\n cloudinary.config(options);\n\n const upload = (file: File, customConfig = {}): Promise<void> => {\n return new Promise((resolve, reject) => {\n const config: Partial<UploadApiOptions> = {\n resource_type: 'auto',\n public_id: file.hash,\n };\n\n if (file.ext) {\n config.filename = `${file.hash}${file.ext}`;\n }\n\n if (file.path) {\n config.folder = file.path;\n }\n\n // For files smaller than 99 MB use regular upload as it tends to be faster\n // and fallback to chunked upload for larger files as that's required by Cloudinary.\n // https://support.cloudinary.com/hc/en-us/community/posts/360009586100-Upload-movie-video-with-large-size?page=1#community_comment_360002140099\n // The Cloudinary's max limit for regular upload is actually 100 MB but add some headroom\n // for size counting shenanigans. (Strapi provides the size in kilobytes rounded to two decimal places here).\n const uploadMethod =\n file.size && file.size < 1000 * 99\n ? cloudinary.uploader.upload_stream\n : cloudinary.uploader.upload_chunked_stream;\n\n const uploadStream = uploadMethod({ ...config, ...customConfig }, (err, image) => {\n if (err) {\n if (err.message.includes('File size too large')) {\n reject(new utils.errors.PayloadTooLargeError());\n } else {\n reject(new Error(`Error uploading to cloudinary: ${err.message}`));\n }\n return;\n }\n\n if (!image) {\n return;\n }\n\n if (image.resource_type === 'video') {\n file.previewUrl = cloudinary.url(`${image.public_id}.gif`, {\n video_sampling: 6,\n delay: 200,\n width: 250,\n crop: 'scale',\n resource_type: 'video',\n });\n }\n\n file.url = image.secure_url;\n file.provider_metadata = {\n public_id: image.public_id,\n resource_type: image.resource_type,\n };\n\n resolve();\n });\n\n if (file.stream) {\n file.stream.pipe(uploadStream);\n } else if (file.buffer) {\n intoStream(file.buffer).pipe(uploadStream);\n } else {\n throw new Error('Missing file stream or buffer');\n }\n });\n };\n\n return {\n uploadStream(file: File, customConfig = {}) {\n return upload(file, customConfig);\n },\n upload(file: File, customConfig = {}) {\n return upload(file, customConfig);\n },\n async delete(file: File, customConfig = {}) {\n try {\n const { resource_type: resourceType, public_id: publicId } = file.provider_metadata ?? {};\n const deleteConfig = {\n resource_type: (resourceType || 'image') as string,\n invalidate: true,\n ...customConfig,\n };\n\n const response = await cloudinary.uploader.destroy(`${publicId}`, deleteConfig);\n\n if (response.result !== 'ok' && response.result !== 'not found') {\n throw new Error(response.result);\n }\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Error deleting on cloudinary: ${error.message}`);\n }\n\n throw error;\n }\n },\n };\n },\n};\n"],"names":["cloudinary","utils","intoStream"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAe,QAAA;AAAA,EACb,KAAK,SAAwB;AAC3BA,eAAA,GAAW,OAAO,OAAO;AAEzB,UAAM,SAAS,CAAC,MAAY,eAAe,CAAA,MAAsB;AAC/D,aAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,cA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A,IACH;AAEO,WAAA;AAAA,MACL,aAAa,MAAY,eAAe,IAAI;AACnC,eAAA,OAAO,MAAM,YAAY;AAAA,MAClC;AAAA,MACA,OAAO,MAAY,eAAe,IAAI;AAC7B,eAAA,OAAO,MAAM,YAAY;AAAA,MAClC;AAAA,MACA,MAAM,OAAO,MAAY,eAAe,IAAI;AACtC,YAAA;AACI,gBAAA,EAAE,eAAe,cAAc,WAAW,aAAa,KAAK,qBAAqB,CAAC;AACxF,gBAAM,eAAe;AAAA,YACnB,eAAgB,gBAAgB;AAAA,YAChC,YAAY;AAAA,YACZ,GAAG;AAAA,UACL;AAEM,gBAAA,WAAW,MAAMF,WAAAA,GAAW,SAAS,QAAQ,GAAG,QAAQ,IAAI,YAAY;AAE9E,cAAI,SAAS,WAAW,QAAQ,SAAS,WAAW,aAAa;AACzD,kBAAA,IAAI,MAAM,SAAS,MAAM;AAAA,UAAA;AAAA,iBAE1B,OAAO;AACd,cAAI,iBAAiB,OAAO;AAC1B,kBAAM,IAAI,MAAM,iCAAiC,MAAM,OAAO,EAAE;AAAA,UAAA;AAG5D,gBAAA;AAAA,QAAA;AAAA,MACR;AAAA,IAEJ;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { ReadStream } from 'node:fs';\nimport { v2 as cloudinary, ConfigOptions, UploadApiOptions } from 'cloudinary';\nimport intoStream from 'into-stream';\nimport * as utils from '@strapi/utils';\n\ninterface File {\n name: string;\n alternativeText?: string;\n caption?: string;\n width?: number;\n height?: number;\n formats?: Record<string, unknown>;\n hash: string;\n ext?: string;\n mime: string;\n size: number;\n sizeInBytes: number;\n url: string;\n previewUrl?: string;\n path?: string;\n provider?: string;\n provider_metadata?: Record<string, unknown>;\n stream?: ReadStream;\n buffer?: Buffer;\n}\n\nexport default {\n init(options: ConfigOptions) {\n cloudinary.config(options);\n\n const upload = (file: File, customConfig = {}): Promise<void> => {\n return new Promise((resolve, reject) => {\n const config: Partial<UploadApiOptions> = {\n resource_type: 'auto',\n public_id: file.hash,\n };\n\n if (file.ext) {\n config.filename = `${file.hash}${file.ext}`;\n }\n\n if (file.path) {\n config.folder = file.path;\n }\n\n // For files smaller than 99 MB use regular upload as it tends to be faster\n // and fallback to chunked upload for larger files as that's required by Cloudinary.\n // https://support.cloudinary.com/hc/en-us/community/posts/360009586100-Upload-movie-video-with-large-size?page=1#community_comment_360002140099\n // The Cloudinary's max limit for regular upload is actually 100 MB but add some headroom\n // for size counting shenanigans. (Strapi provides the size in kilobytes rounded to two decimal places here).\n const uploadMethod =\n file.size && file.size < 1000 * 99\n ? cloudinary.uploader.upload_stream\n : cloudinary.uploader.upload_chunked_stream;\n\n const uploadStream = uploadMethod({ ...config, ...customConfig }, (err, image) => {\n if (err) {\n if (err.message.includes('File size too large')) {\n reject(new utils.errors.PayloadTooLargeError());\n } else {\n reject(new Error(`Error uploading to cloudinary: ${err.message}`));\n }\n return;\n }\n\n if (!image) {\n return;\n }\n\n if (image.resource_type === 'video') {\n file.previewUrl = cloudinary.url(`${image.public_id}.gif`, {\n video_sampling: 6,\n delay: 200,\n width: 250,\n crop: 'scale',\n resource_type: 'video',\n });\n }\n\n file.url = image.secure_url;\n file.provider_metadata = {\n public_id: image.public_id,\n resource_type: image.resource_type,\n };\n\n resolve();\n });\n\n if (file.stream) {\n file.stream.pipe(uploadStream);\n } else if (file.buffer) {\n intoStream(file.buffer).pipe(uploadStream);\n } else {\n throw new Error('Missing file stream or buffer');\n }\n });\n };\n\n return {\n uploadStream(file: File, customConfig = {}) {\n return upload(file, customConfig);\n },\n upload(file: File, customConfig = {}) {\n return upload(file, customConfig);\n },\n async delete(file: File, customConfig = {}) {\n try {\n const { resource_type: resourceType, public_id: publicId } = file.provider_metadata ?? {};\n const deleteConfig = {\n resource_type: (resourceType || 'image') as string,\n invalidate: true,\n ...customConfig,\n };\n\n const response = await cloudinary.uploader.destroy(`${publicId}`, deleteConfig);\n\n if (response.result !== 'ok' && response.result !== 'not found') {\n throw new Error(response.result);\n }\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Error deleting on cloudinary: ${error.message}`);\n }\n\n throw error;\n }\n },\n };\n },\n};\n"],"names":["init","options","cloudinary","config","upload","file","customConfig","Promise","resolve","reject","resource_type","public_id","hash","ext","filename","path","folder","uploadMethod","size","uploader","upload_stream","upload_chunked_stream","uploadStream","err","image","message","includes","utils","errors","PayloadTooLargeError","Error","previewUrl","url","video_sampling","delay","width","crop","secure_url","provider_metadata","stream","pipe","buffer","intoStream","delete","resourceType","publicId","deleteConfig","invalidate","response","destroy","result","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,YAAe;AACbA,IAAAA,IAAAA,CAAAA,CAAKC,OAAsB,EAAA;AACzBC,QAAAA,aAAAA,CAAWC,MAAM,CAACF,OAAAA,CAAAA;AAElB,QAAA,MAAMG,MAAS,GAAA,CAACC,IAAYC,EAAAA,YAAAA,GAAe,EAAE,GAAA;YAC3C,OAAO,IAAIC,OAAQ,CAAA,CAACC,OAASC,EAAAA,MAAAA,GAAAA;AAC3B,gBAAA,MAAMN,MAAoC,GAAA;oBACxCO,aAAe,EAAA,MAAA;AACfC,oBAAAA,SAAAA,EAAWN,KAAKO;AAClB,iBAAA;gBAEA,IAAIP,IAAAA,CAAKQ,GAAG,EAAE;oBACZV,MAAOW,CAAAA,QAAQ,GAAG,CAAC,EAAET,IAAAA,CAAKO,IAAI,CAAC,EAAEP,IAAAA,CAAKQ,GAAG,CAAC,CAAC;AAC7C;gBAEA,IAAIR,IAAAA,CAAKU,IAAI,EAAE;oBACbZ,MAAOa,CAAAA,MAAM,GAAGX,IAAAA,CAAKU,IAAI;AAC3B;;;;;;AAOA,gBAAA,MAAME,eACJZ,IAAKa,CAAAA,IAAI,IAAIb,IAAAA,CAAKa,IAAI,GAAG,IAAA,GAAO,EAC5BhB,GAAAA,aAAAA,CAAWiB,QAAQ,CAACC,aAAa,GACjClB,aAAWiB,CAAAA,QAAQ,CA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A,IAAIA,iBAAiBrB,KAAO,EAAA;wBAC1B,MAAM,IAAIA,MAAM,CAAC,8BAA8B,EAAEqB,KAAM1B,CAAAA,OAAO,CAAC,CAAC,CAAA;AAClE;oBAEA,MAAM0B,KAAAA;AACR;AACF;AACF,SAAA;AACF;AACF,CAAE;;;;"}
package/dist/index.mjs CHANGED
@@ -1,89 +1,97 @@
1
- import { v2 } from "cloudinary";
2
- import intoStream from "into-stream";
3
- import * as utils from "@strapi/utils";
4
- const index = {
5
- init(options) {
6
- v2.config(options);
7
- const upload = (file, customConfig = {}) => {
8
- return new Promise((resolve, reject) => {
9
- const config = {
10
- resource_type: "auto",
11
- public_id: file.hash
1
+ import { v2 } from 'cloudinary';
2
+ import intoStream from 'into-stream';
3
+ import * as utils from '@strapi/utils';
4
+
5
+ var index = {
6
+ init (options) {
7
+ v2.config(options);
8
+ const upload = (file, customConfig = {})=>{
9
+ return new Promise((resolve, reject)=>{
10
+ const config = {
11
+ resource_type: 'auto',
12
+ public_id: file.hash
13
+ };
14
+ if (file.ext) {
15
+ config.filename = `${file.hash}${file.ext}`;
16
+ }
17
+ if (file.path) {
18
+ config.folder = file.path;
19
+ }
20
+ // For files smaller than 99 MB use regular upload as it tends to be faster
21
+ // and fallback to chunked upload for larger files as that's required by Cloudinary.
22
+ // https://support.cloudinary.com/hc/en-us/community/posts/360009586100-Upload-movie-video-with-large-size?page=1#community_comment_360002140099
23
+ // The Cloudinary's max limit for regular upload is actually 100 MB but add some headroom
24
+ // for size counting shenanigans. (Strapi provides the size in kilobytes rounded to two decimal places here).
25
+ const uploadMethod = file.size && file.size < 1000 * 99 ? v2.uploader.upload_stream : v2.uploader.upload_chunked_stream;
26
+ const uploadStream = uploadMethod({
27
+ ...config,
28
+ ...customConfig
29
+ }, (err, image)=>{
30
+ if (err) {
31
+ if (err.message.includes('File size too large')) {
32
+ reject(new utils.errors.PayloadTooLargeError());
33
+ } else {
34
+ reject(new Error(`Error uploading to cloudinary: ${err.message}`));
35
+ }
36
+ return;
37
+ }
38
+ if (!image) {
39
+ return;
40
+ }
41
+ if (image.resource_type === 'video') {
42
+ file.previewUrl = v2.url(`${image.public_id}.gif`, {
43
+ video_sampling: 6,
44
+ delay: 200,
45
+ width: 250,
46
+ crop: 'scale',
47
+ resource_type: 'video'
48
+ });
49
+ }
50
+ file.url = image.secure_url;
51
+ file.provider_metadata = {
52
+ public_id: image.public_id,
53
+ resource_type: image.resource_type
54
+ };
55
+ resolve();
56
+ });
57
+ if (file.stream) {
58
+ file.stream.pipe(uploadStream);
59
+ } else if (file.buffer) {
60
+ intoStream(file.buffer).pipe(uploadStream);
61
+ } else {
62
+ throw new Error('Missing file stream or buffer');
63
+ }
64
+ });
12
65
  };
13
- if (file.ext) {
14
- config.filename = `${file.hash}${file.ext}`;
15
- }
16
- if (file.path) {
17
- config.folder = file.path;
18
- }
19
- const uploadMethod = file.size && file.size < 1e3 * 99 ? v2.uploader.upload_stream : v2.uploader.upload_chunked_stream;
20
- const uploadStream = uploadMethod({ ...config, ...customConfig }, (err, image) => {
21
- if (err) {
22
- if (err.message.includes("File size too large")) {
23
- reject(new utils.errors.PayloadTooLargeError());
24
- } else {
25
- reject(new Error(`Error uploading to cloudinary: ${err.message}`));
66
+ return {
67
+ uploadStream (file, customConfig = {}) {
68
+ return upload(file, customConfig);
69
+ },
70
+ upload (file, customConfig = {}) {
71
+ return upload(file, customConfig);
72
+ },
73
+ async delete (file, customConfig = {}) {
74
+ try {
75
+ const { resource_type: resourceType, public_id: publicId } = file.provider_metadata ?? {};
76
+ const deleteConfig = {
77
+ resource_type: resourceType || 'image',
78
+ invalidate: true,
79
+ ...customConfig
80
+ };
81
+ const response = await v2.uploader.destroy(`${publicId}`, deleteConfig);
82
+ if (response.result !== 'ok' && response.result !== 'not found') {
83
+ throw new Error(response.result);
84
+ }
85
+ } catch (error) {
86
+ if (error instanceof Error) {
87
+ throw new Error(`Error deleting on cloudinary: ${error.message}`);
88
+ }
89
+ throw error;
90
+ }
26
91
  }
27
- return;
28
- }
29
- if (!image) {
30
- return;
31
- }
32
- if (image.resource_type === "video") {
33
- file.previewUrl = v2.url(`${image.public_id}.gif`, {
34
- video_sampling: 6,
35
- delay: 200,
36
- width: 250,
37
- crop: "scale",
38
- resource_type: "video"
39
- });
40
- }
41
- file.url = image.secure_url;
42
- file.provider_metadata = {
43
- public_id: image.public_id,
44
- resource_type: image.resource_type
45
- };
46
- resolve();
47
- });
48
- if (file.stream) {
49
- file.stream.pipe(uploadStream);
50
- } else if (file.buffer) {
51
- intoStream(file.buffer).pipe(uploadStream);
52
- } else {
53
- throw new Error("Missing file stream or buffer");
54
- }
55
- });
56
- };
57
- return {
58
- uploadStream(file, customConfig = {}) {
59
- return upload(file, customConfig);
60
- },
61
- upload(file, customConfig = {}) {
62
- return upload(file, customConfig);
63
- },
64
- async delete(file, customConfig = {}) {
65
- try {
66
- const { resource_type: resourceType, public_id: publicId } = file.provider_metadata ?? {};
67
- const deleteConfig = {
68
- resource_type: resourceType || "image",
69
- invalidate: true,
70
- ...customConfig
71
- };
72
- const response = await v2.uploader.destroy(`${publicId}`, deleteConfig);
73
- if (response.result !== "ok" && response.result !== "not found") {
74
- throw new Error(response.result);
75
- }
76
- } catch (error) {
77
- if (error instanceof Error) {
78
- throw new Error(`Error deleting on cloudinary: ${error.message}`);
79
- }
80
- throw error;
81
- }
82
- }
83
- };
84
- }
85
- };
86
- export {
87
- index as default
92
+ };
93
+ }
88
94
  };
95
+
96
+ export { index as default };
89
97
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import type { ReadStream } from 'node:fs';\nimport { v2 as cloudinary, ConfigOptions, UploadApiOptions } from 'cloudinary';\nimport intoStream from 'into-stream';\nimport * as utils from '@strapi/utils';\n\ninterface File {\n name: string;\n alternativeText?: string;\n caption?: string;\n width?: number;\n height?: number;\n formats?: Record<string, unknown>;\n hash: string;\n ext?: string;\n mime: string;\n size: number;\n sizeInBytes: number;\n url: string;\n previewUrl?: string;\n path?: string;\n provider?: string;\n provider_metadata?: Record<string, unknown>;\n stream?: ReadStream;\n buffer?: Buffer;\n}\n\nexport default {\n init(options: ConfigOptions) {\n cloudinary.config(options);\n\n const upload = (file: File, customConfig = {}): Promise<void> => {\n return new Promise((resolve, reject) => {\n const config: Partial<UploadApiOptions> = {\n resource_type: 'auto',\n public_id: file.hash,\n };\n\n if (file.ext) {\n config.filename = `${file.hash}${file.ext}`;\n }\n\n if (file.path) {\n config.folder = file.path;\n }\n\n // For files smaller than 99 MB use regular upload as it tends to be faster\n // and fallback to chunked upload for larger files as that's required by Cloudinary.\n // https://support.cloudinary.com/hc/en-us/community/posts/360009586100-Upload-movie-video-with-large-size?page=1#community_comment_360002140099\n // The Cloudinary's max limit for regular upload is actually 100 MB but add some headroom\n // for size counting shenanigans. (Strapi provides the size in kilobytes rounded to two decimal places here).\n const uploadMethod =\n file.size && file.size < 1000 * 99\n ? cloudinary.uploader.upload_stream\n : cloudinary.uploader.upload_chunked_stream;\n\n const uploadStream = uploadMethod({ ...config, ...customConfig }, (err, image) => {\n if (err) {\n if (err.message.includes('File size too large')) {\n reject(new utils.errors.PayloadTooLargeError());\n } else {\n reject(new Error(`Error uploading to cloudinary: ${err.message}`));\n }\n return;\n }\n\n if (!image) {\n return;\n }\n\n if (image.resource_type === 'video') {\n file.previewUrl = cloudinary.url(`${image.public_id}.gif`, {\n video_sampling: 6,\n delay: 200,\n width: 250,\n crop: 'scale',\n resource_type: 'video',\n });\n }\n\n file.url = image.secure_url;\n file.provider_metadata = {\n public_id: image.public_id,\n resource_type: image.resource_type,\n };\n\n resolve();\n });\n\n if (file.stream) {\n file.stream.pipe(uploadStream);\n } else if (file.buffer) {\n intoStream(file.buffer).pipe(uploadStream);\n } else {\n throw new Error('Missing file stream or buffer');\n }\n });\n };\n\n return {\n uploadStream(file: File, customConfig = {}) {\n return upload(file, customConfig);\n },\n upload(file: File, customConfig = {}) {\n return upload(file, customConfig);\n },\n async delete(file: File, customConfig = {}) {\n try {\n const { resource_type: resourceType, public_id: publicId } = file.provider_metadata ?? {};\n const deleteConfig = {\n resource_type: (resourceType || 'image') as string,\n invalidate: true,\n ...customConfig,\n };\n\n const response = await cloudinary.uploader.destroy(`${publicId}`, deleteConfig);\n\n if (response.result !== 'ok' && response.result !== 'not found') {\n throw new Error(response.result);\n }\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Error deleting on cloudinary: ${error.message}`);\n }\n\n throw error;\n }\n },\n };\n },\n};\n"],"names":["cloudinary"],"mappings":";;;AA0BA,MAAe,QAAA;AAAA,EACb,KAAK,SAAwB;AAC3BA,OAAW,OAAO,OAAO;AAEzB,UAAM,SAAS,CAAC,MAAY,eAAe,CAAA,MAAsB;AAC/D,aAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,cAAM,SAAoC;AAAA,UACxC,eAAe;AAAA,UACf,WAAW,KAAK;AAAA,QAClB;AAEA,YAAI,KAAK,KAAK;AACZ,iBAAO,WAAW,GAAG,KAAK,IAAI,GAAG,KAAK,GAAG;AAAA,QAAA;AAG3C,YAAI,KAAK,MAAM;AACb,iBAAO,SAAS,KAAK;AAAA,QAAA;AAQjB,cAAA,eACJ,KAAK,QAAQ,KAAK,OAAO,MAAO,KAC5BA,GAAW,SAAS,gBACpBA,GAAW,SAAS;AAEpB,cAAA,eAAe,aAAa,EAAE,GAAG,QAAQ,GAAG,aAAa,GAAG,CAAC,KAAK,UAAU;AAChF,cAAI,KAAK;AACP,gBAAI,IAAI,QAAQ,SAAS,qBAAqB,GAAG;AAC/C,qBAAO,IAAI,MAAM,OAAO,qBAAA,CAAsB;AAAA,YAAA,OACzC;AACL,qBAAO,IAAI,MAAM,kCAAkC,IAAI,OAAO,EAAE,CAAC;AAAA,YAAA;AAEnE;AAAA,UAAA;AAGF,cAAI,CAAC,OAAO;AACV;AAAA,UAAA;AAGE,cAAA,MAAM,kBAAkB,SAAS;AACnC,iBAAK,aAAaA,GA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J;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import type { ReadStream } from 'node:fs';\nimport { v2 as cloudinary, ConfigOptions, UploadApiOptions } from 'cloudinary';\nimport intoStream from 'into-stream';\nimport * as utils from '@strapi/utils';\n\ninterface File {\n name: string;\n alternativeText?: string;\n caption?: string;\n width?: number;\n height?: number;\n formats?: Record<string, unknown>;\n hash: string;\n ext?: string;\n mime: string;\n size: number;\n sizeInBytes: number;\n url: string;\n previewUrl?: string;\n path?: string;\n provider?: string;\n provider_metadata?: Record<string, unknown>;\n stream?: ReadStream;\n buffer?: Buffer;\n}\n\nexport default {\n init(options: ConfigOptions) {\n cloudinary.config(options);\n\n const upload = (file: File, customConfig = {}): Promise<void> => {\n return new Promise((resolve, reject) => {\n const config: Partial<UploadApiOptions> = {\n resource_type: 'auto',\n public_id: file.hash,\n };\n\n if (file.ext) {\n config.filename = `${file.hash}${file.ext}`;\n }\n\n if (file.path) {\n config.folder = file.path;\n }\n\n // For files smaller than 99 MB use regular upload as it tends to be faster\n // and fallback to chunked upload for larger files as that's required by Cloudinary.\n // https://support.cloudinary.com/hc/en-us/community/posts/360009586100-Upload-movie-video-with-large-size?page=1#community_comment_360002140099\n // The Cloudinary's max limit for regular upload is actually 100 MB but add some headroom\n // for size counting shenanigans. (Strapi provides the size in kilobytes rounded to two decimal places here).\n const uploadMethod =\n file.size && file.size < 1000 * 99\n ? cloudinary.uploader.upload_stream\n : cloudinary.uploader.upload_chunked_stream;\n\n const uploadStream = uploadMethod({ ...config, ...customConfig }, (err, image) => {\n if (err) {\n if (err.message.includes('File size too large')) {\n reject(new utils.errors.PayloadTooLargeError());\n } else {\n reject(new Error(`Error uploading to cloudinary: ${err.message}`));\n }\n return;\n }\n\n if (!image) {\n return;\n }\n\n if (image.resource_type === 'video') {\n file.previewUrl = cloudinary.url(`${image.public_id}.gif`, {\n video_sampling: 6,\n delay: 200,\n width: 250,\n crop: 'scale',\n resource_type: 'video',\n });\n }\n\n file.url = image.secure_url;\n file.provider_metadata = {\n public_id: image.public_id,\n resource_type: image.resource_type,\n };\n\n resolve();\n });\n\n if (file.stream) {\n file.stream.pipe(uploadStream);\n } else if (file.buffer) {\n intoStream(file.buffer).pipe(uploadStream);\n } else {\n throw new Error('Missing file stream or buffer');\n }\n });\n };\n\n return {\n uploadStream(file: File, customConfig = {}) {\n return upload(file, customConfig);\n },\n upload(file: File, customConfig = {}) {\n return upload(file, customConfig);\n },\n async delete(file: File, customConfig = {}) {\n try {\n const { resource_type: resourceType, public_id: publicId } = file.provider_metadata ?? {};\n const deleteConfig = {\n resource_type: (resourceType || 'image') as string,\n invalidate: true,\n ...customConfig,\n };\n\n const response = await cloudinary.uploader.destroy(`${publicId}`, deleteConfig);\n\n if (response.result !== 'ok' && response.result !== 'not found') {\n throw new Error(response.result);\n }\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Error deleting on cloudinary: ${error.message}`);\n }\n\n throw error;\n }\n },\n };\n },\n};\n"],"names":["init","options","cloudinary","config","upload","file","customConfig","Promise","resolve","reject","resource_type","public_id","hash","ext","filename","path","folder","uploadMethod","size","uploader","upload_stream","upload_chunked_stream","uploadStream","err","image","message","includes","utils","errors","PayloadTooLargeError","Error","previewUrl","url","video_sampling","delay","width","crop","secure_url","provider_metadata","stream","pipe","buffer","intoStream","delete","resourceType","publicId","deleteConfig","invalidate","response","destroy","result","error"],"mappings":";;;;AA0BA,YAAe;AACbA,IAAAA,IAAAA,CAAAA,CAAKC,OAAsB,EAAA;AACzBC,QAAAA,EAAAA,CAAWC,MAAM,CAACF,OAAAA,CAAAA;AAElB,QAAA,MAAMG,MAAS,GAAA,CAACC,IAAYC,EAAAA,YAAAA,GAAe,EAAE,GAAA;YAC3C,OAAO,IAAIC,OAAQ,CAAA,CAACC,OAASC,EAAAA,MAAAA,GAAAA;AAC3B,gBAAA,MAAMN,MAAoC,GAAA;oBACxCO,aAAe,EAAA,MAAA;AACfC,oBAAAA,SAAAA,EAAWN,KA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MAAMQ,YAAe,GAAA;AACnBpC,wBAAAA,aAAAA,EAAgBkC,YAAgB,IAAA,OAAA;wBAChCG,UAAY,EAAA,IAAA;AACZ,wBAAA,GAAGzC;AACL,qBAAA;oBAEA,MAAM0C,QAAAA,GAAW,MAAM9C,EAAAA,CAAWiB,QAAQ,CAAC8B,OAAO,CAAC,CAAC,EAAEJ,QAAS,CAAA,CAAC,EAAEC,YAAAA,CAAAA;AAElE,oBAAA,IAAIE,SAASE,MAAM,KAAK,QAAQF,QAASE,CAAAA,MAAM,KAAK,WAAa,EAAA;wBAC/D,MAAM,IAAIpB,KAAMkB,CAAAA,QAAAA,CAASE,MAAM,CAAA;AACjC;AACF,iBAAA,CAAE,OAAOC,KAAO,EAAA;AACd,oBAAA,IAAIA,iBAAiBrB,KAAO,EAAA;wBAC1B,MAAM,IAAIA,MAAM,CAAC,8BAA8B,EAAEqB,KAAM1B,CAAAA,OAAO,CAAC,CAAC,CAAA;AAClE;oBAEA,MAAM0B,KAAAA;AACR;AACF;AACF,SAAA;AACF;AACF,CAAE;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/provider-upload-cloudinary",
3
- "version": "5.8.1",
3
+ "version": "5.10.0",
4
4
  "description": "Cloudinary provider for strapi upload",
5
5
  "keywords": [
6
6
  "upload",
@@ -36,20 +36,21 @@
36
36
  "dist/"
37
37
  ],
38
38
  "scripts": {
39
- "build": "pack-up build",
39
+ "build": "run -T npm-run-all clean --parallel build:code build:types",
40
+ "build:code": "run -T rollup -c",
41
+ "build:types": "run -T tsc -p tsconfig.build.json --emitDeclarationOnly",
40
42
  "clean": "run -T rimraf ./dist",
41
43
  "lint": "run -T eslint .",
42
- "watch": "pack-up watch"
44
+ "watch": "run -T rollup -c -w"
43
45
  },
44
46
  "dependencies": {
45
- "@strapi/utils": "5.8.1",
47
+ "@strapi/utils": "5.10.0",
46
48
  "cloudinary": "^1.41.0",
47
49
  "into-stream": "^5.1.0"
48
50
  },
49
51
  "devDependencies": {
50
- "@strapi/pack-up": "5.0.2",
51
- "eslint-config-custom": "5.8.1",
52
- "tsconfig": "5.8.1"
52
+ "eslint-config-custom": "5.10.0",
53
+ "tsconfig": "5.10.0"
53
54
  },
54
55
  "engines": {
55
56
  "node": ">=18.0.0 <=22.x.x",