next-tinacms-cloudinary 3.2.5 → 3.3.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/CHANGELOG.md +6 -0
- package/dist/handlers.js +1 -1
- package/dist/index.es.js +28 -24
- package/dist/index.js +28 -24
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/handlers.js
CHANGED
|
@@ -57,7 +57,7 @@ var mediaHandlerConfig = {
|
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
var createMediaHandler = (config) => {
|
|
60
|
-
import_cloudinary.v2.config(config);
|
|
60
|
+
import_cloudinary.v2.config(Object.assign({ secure: true }, config));
|
|
61
61
|
return (req, res) => __async(void 0, null, function* () {
|
|
62
62
|
const isAuthorized = yield config.authorized(req, res);
|
|
63
63
|
if (!isAuthorized) {
|
package/dist/index.es.js
CHANGED
|
@@ -52,31 +52,35 @@ class CloudinaryMediaStore {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
async persist(media) {
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
let newFiles = [];
|
|
56
|
+
for (const item of media) {
|
|
57
|
+
const { file, directory } = item;
|
|
58
|
+
const formData = new FormData();
|
|
59
|
+
formData.append("file", file);
|
|
60
|
+
formData.append("directory", directory);
|
|
61
|
+
formData.append("filename", file.name);
|
|
62
|
+
const res = await this.fetchFunction(`/api/cloudinary/media`, {
|
|
63
|
+
method: "POST",
|
|
64
|
+
body: formData
|
|
65
|
+
});
|
|
66
|
+
if (res.status != 200) {
|
|
67
|
+
const responseData = await res.json();
|
|
68
|
+
throw new Error(responseData.message);
|
|
69
|
+
}
|
|
70
|
+
const fileRes = await res.json();
|
|
71
|
+
await new Promise((resolve) => {
|
|
72
|
+
setTimeout(resolve, 2e3);
|
|
73
|
+
});
|
|
74
|
+
const parsedRes = {
|
|
75
|
+
type: "file",
|
|
76
|
+
id: fileRes.public_id,
|
|
77
|
+
filename: fileRes.original_filename,
|
|
78
|
+
directory: "/",
|
|
79
|
+
previewSrc: fileRes.url
|
|
80
|
+
};
|
|
81
|
+
newFiles.push(parsedRes);
|
|
67
82
|
}
|
|
68
|
-
|
|
69
|
-
await new Promise((resolve) => {
|
|
70
|
-
setTimeout(resolve, 2e3);
|
|
71
|
-
});
|
|
72
|
-
const parsedRes = {
|
|
73
|
-
type: "file",
|
|
74
|
-
id: fileRes.public_id,
|
|
75
|
-
filename: fileRes.original_filename,
|
|
76
|
-
directory: "/",
|
|
77
|
-
previewSrc: fileRes.url
|
|
78
|
-
};
|
|
79
|
-
return [parsedRes];
|
|
83
|
+
return newFiles;
|
|
80
84
|
}
|
|
81
85
|
async delete(media) {
|
|
82
86
|
await this.fetchFunction(`/api/cloudinary/media/${encodeURIComponent(media.id)}`, {
|
package/dist/index.js
CHANGED
|
@@ -55,31 +55,35 @@
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
async persist(media) {
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
let newFiles = [];
|
|
59
|
+
for (const item of media) {
|
|
60
|
+
const { file, directory } = item;
|
|
61
|
+
const formData = new FormData();
|
|
62
|
+
formData.append("file", file);
|
|
63
|
+
formData.append("directory", directory);
|
|
64
|
+
formData.append("filename", file.name);
|
|
65
|
+
const res = await this.fetchFunction(`/api/cloudinary/media`, {
|
|
66
|
+
method: "POST",
|
|
67
|
+
body: formData
|
|
68
|
+
});
|
|
69
|
+
if (res.status != 200) {
|
|
70
|
+
const responseData = await res.json();
|
|
71
|
+
throw new Error(responseData.message);
|
|
72
|
+
}
|
|
73
|
+
const fileRes = await res.json();
|
|
74
|
+
await new Promise((resolve) => {
|
|
75
|
+
setTimeout(resolve, 2e3);
|
|
76
|
+
});
|
|
77
|
+
const parsedRes = {
|
|
78
|
+
type: "file",
|
|
79
|
+
id: fileRes.public_id,
|
|
80
|
+
filename: fileRes.original_filename,
|
|
81
|
+
directory: "/",
|
|
82
|
+
previewSrc: fileRes.url
|
|
83
|
+
};
|
|
84
|
+
newFiles.push(parsedRes);
|
|
70
85
|
}
|
|
71
|
-
|
|
72
|
-
await new Promise((resolve) => {
|
|
73
|
-
setTimeout(resolve, 2e3);
|
|
74
|
-
});
|
|
75
|
-
const parsedRes = {
|
|
76
|
-
type: "file",
|
|
77
|
-
id: fileRes.public_id,
|
|
78
|
-
filename: fileRes.original_filename,
|
|
79
|
-
directory: "/",
|
|
80
|
-
previewSrc: fileRes.url
|
|
81
|
-
};
|
|
82
|
-
return [parsedRes];
|
|
86
|
+
return newFiles;
|
|
83
87
|
}
|
|
84
88
|
async delete(media) {
|
|
85
89
|
await this.fetchFunction(`/api/cloudinary/media/${encodeURIComponent(media.id)}`, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-tinacms-cloudinary",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"multer": "^1.4.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@tinacms/toolkit": "0.
|
|
29
|
+
"@tinacms/toolkit": "0.54.0",
|
|
30
30
|
"@types/crypto-js": "^3.1.47",
|
|
31
31
|
"@types/js-cookie": "^2.2.6",
|
|
32
32
|
"@types/node": "^13.13.1",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"react": "16.13.1",
|
|
37
37
|
"react-dom": "16.13.1",
|
|
38
38
|
"styled-components": "^5.2.0",
|
|
39
|
-
"tinacms": "0.
|
|
39
|
+
"tinacms": "0.56.0",
|
|
40
40
|
"tsup": "4.12.5",
|
|
41
41
|
"typescript": "^4.3.5"
|
|
42
42
|
},
|