@strapi/provider-upload-local 5.9.0 → 5.10.1
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 +86 -97
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -86
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -1,115 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var stream = require('stream');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var fse = require('fs-extra');
|
|
7
|
+
var utils = require('@strapi/utils');
|
|
8
|
+
|
|
9
|
+
function _interopNamespaceDefault(e) {
|
|
10
|
+
var n = Object.create(null);
|
|
11
11
|
if (e) {
|
|
12
|
-
|
|
13
|
-
if (k !==
|
|
14
|
-
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
15
|
Object.defineProperty(n, k, d.get ? d : {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: ()
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
}
|
|
20
|
+
});
|
|
21
21
|
}
|
|
22
22
|
n.default = e;
|
|
23
23
|
return Object.freeze(n);
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const utils__namespace = /* @__PURE__ */ _interopNamespace(utils);
|
|
25
|
+
|
|
26
|
+
var utils__namespace = /*#__PURE__*/_interopNamespaceDefault(utils);
|
|
27
|
+
|
|
29
28
|
const { PayloadTooLargeError } = utils__namespace.errors;
|
|
30
29
|
const { kbytesToBytes, bytesToHumanReadable } = utils__namespace.file;
|
|
31
|
-
const UPLOADS_FOLDER_NAME =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
process.emitWarning(
|
|
36
|
-
'[deprecated] In future versions, "sizeLimit" argument will be ignored from upload.config.providerOptions. Move it to upload.config'
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
const uploadPath = path__default.default.resolve(strapi.dirs.static.public, UPLOADS_FOLDER_NAME);
|
|
40
|
-
if (!fse__default.default.pathExistsSync(uploadPath)) {
|
|
41
|
-
throw new Error(
|
|
42
|
-
`The upload folder (${uploadPath}) doesn't exist or is not accessible. Please make sure it exists.`
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
checkFileSize(file, options) {
|
|
47
|
-
const { sizeLimit } = options ?? {};
|
|
30
|
+
const UPLOADS_FOLDER_NAME = 'uploads';
|
|
31
|
+
var index = {
|
|
32
|
+
init ({ sizeLimit: providerOptionsSizeLimit } = {}) {
|
|
33
|
+
// TODO V5: remove providerOptions sizeLimit
|
|
48
34
|
if (providerOptionsSizeLimit) {
|
|
49
|
-
|
|
50
|
-
throw new PayloadTooLargeError(
|
|
51
|
-
`${file.name} exceeds size limit of ${bytesToHumanReadable(
|
|
52
|
-
providerOptionsSizeLimit
|
|
53
|
-
)}.`
|
|
54
|
-
);
|
|
55
|
-
} else if (sizeLimit) {
|
|
56
|
-
if (kbytesToBytes(file.size) > sizeLimit)
|
|
57
|
-
throw new PayloadTooLargeError(
|
|
58
|
-
`${file.name} exceeds size limit of ${bytesToHumanReadable(sizeLimit)}.`
|
|
59
|
-
);
|
|
35
|
+
process.emitWarning('[deprecated] In future versions, "sizeLimit" argument will be ignored from upload.config.providerOptions. Move it to upload.config');
|
|
60
36
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
const { stream: stream$1 } = file;
|
|
67
|
-
return new Promise((resolve, reject) => {
|
|
68
|
-
stream.pipeline(
|
|
69
|
-
stream$1,
|
|
70
|
-
fs__default.default.createWriteStream(path__default.default.join(uploadPath, `${file.hash}${file.ext}`)),
|
|
71
|
-
(err) => {
|
|
72
|
-
if (err) {
|
|
73
|
-
return reject(err);
|
|
74
|
-
}
|
|
75
|
-
file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;
|
|
76
|
-
resolve();
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
},
|
|
81
|
-
upload(file) {
|
|
82
|
-
if (!file.buffer) {
|
|
83
|
-
return Promise.reject(new Error("Missing file buffer"));
|
|
37
|
+
// Ensure uploads folder exists
|
|
38
|
+
const uploadPath = path.resolve(strapi.dirs.static.public, UPLOADS_FOLDER_NAME);
|
|
39
|
+
if (!fse.pathExistsSync(uploadPath)) {
|
|
40
|
+
throw new Error(`The upload folder (${uploadPath}) doesn't exist or is not accessible. Please make sure it exists.`);
|
|
84
41
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
42
|
+
return {
|
|
43
|
+
checkFileSize (file, options) {
|
|
44
|
+
const { sizeLimit } = options ?? {};
|
|
45
|
+
// TODO V5: remove providerOptions sizeLimit
|
|
46
|
+
if (providerOptionsSizeLimit) {
|
|
47
|
+
if (kbytesToBytes(file.size) > providerOptionsSizeLimit) throw new PayloadTooLargeError(`${file.name} exceeds size limit of ${bytesToHumanReadable(providerOptionsSizeLimit)}.`);
|
|
48
|
+
} else if (sizeLimit) {
|
|
49
|
+
if (kbytesToBytes(file.size) > sizeLimit) throw new PayloadTooLargeError(`${file.name} exceeds size limit of ${bytesToHumanReadable(sizeLimit)}.`);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
uploadStream (file) {
|
|
53
|
+
if (!file.stream) {
|
|
54
|
+
return Promise.reject(new Error('Missing file stream'));
|
|
55
|
+
}
|
|
56
|
+
const { stream: stream$1 } = file;
|
|
57
|
+
return new Promise((resolve, reject)=>{
|
|
58
|
+
stream.pipeline(stream$1, fs.createWriteStream(path.join(uploadPath, `${file.hash}${file.ext}`)), (err)=>{
|
|
59
|
+
if (err) {
|
|
60
|
+
return reject(err);
|
|
61
|
+
}
|
|
62
|
+
file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;
|
|
63
|
+
resolve();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
upload (file) {
|
|
68
|
+
if (!file.buffer) {
|
|
69
|
+
return Promise.reject(new Error('Missing file buffer'));
|
|
70
|
+
}
|
|
71
|
+
const { buffer } = file;
|
|
72
|
+
return new Promise((resolve, reject)=>{
|
|
73
|
+
// write file in public/assets folder
|
|
74
|
+
fs.writeFile(path.join(uploadPath, `${file.hash}${file.ext}`), buffer, (err)=>{
|
|
75
|
+
if (err) {
|
|
76
|
+
return reject(err);
|
|
77
|
+
}
|
|
78
|
+
file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;
|
|
79
|
+
resolve();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
delete (file) {
|
|
84
|
+
return new Promise((resolve, reject)=>{
|
|
85
|
+
const filePath = path.join(uploadPath, `${file.hash}${file.ext}`);
|
|
86
|
+
if (!fs.existsSync(filePath)) {
|
|
87
|
+
resolve("File doesn't exist");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// remove file from public/assets folder
|
|
91
|
+
fs.unlink(filePath, (err)=>{
|
|
92
|
+
if (err) {
|
|
93
|
+
return reject(err);
|
|
94
|
+
}
|
|
95
|
+
resolve();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
90
98
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
delete(file) {
|
|
97
|
-
return new Promise((resolve, reject) => {
|
|
98
|
-
const filePath = path__default.default.join(uploadPath, `${file.hash}${file.ext}`);
|
|
99
|
-
if (!fs__default.default.existsSync(filePath)) {
|
|
100
|
-
resolve("File doesn't exist");
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
fs__default.default.unlink(filePath, (err) => {
|
|
104
|
-
if (err) {
|
|
105
|
-
return reject(err);
|
|
106
|
-
}
|
|
107
|
-
resolve();
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
113
101
|
};
|
|
102
|
+
|
|
114
103
|
module.exports = index;
|
|
115
104
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { pipeline } from 'stream';\nimport fs, { ReadStream } from 'fs';\nimport path from 'path';\nimport fse from 'fs-extra';\nimport * as utils from '@strapi/utils';\n\n// Needed to load global.strapi without having to put @strapi/types in the regular dependencies\nimport type {} from '@strapi/types';\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\nconst { PayloadTooLargeError } = utils.errors;\nconst { kbytesToBytes, bytesToHumanReadable } = utils.file;\n\nconst UPLOADS_FOLDER_NAME = 'uploads';\n\ninterface InitOptions {\n sizeLimit?: number;\n}\n\ninterface CheckFileSizeOptions {\n sizeLimit?: number;\n}\n\nexport default {\n init({ sizeLimit: providerOptionsSizeLimit }: InitOptions = {}) {\n // TODO V5: remove providerOptions sizeLimit\n if (providerOptionsSizeLimit) {\n process.emitWarning(\n '[deprecated] In future versions, \"sizeLimit\" argument will be ignored from upload.config.providerOptions. Move it to upload.config'\n );\n }\n\n // Ensure uploads folder exists\n const uploadPath = path.resolve(strapi.dirs.static.public, UPLOADS_FOLDER_NAME);\n if (!fse.pathExistsSync(uploadPath)) {\n throw new Error(\n `The upload folder (${uploadPath}) doesn't exist or is not accessible. Please make sure it exists.`\n );\n }\n\n return {\n checkFileSize(file: File, options: CheckFileSizeOptions) {\n const { sizeLimit } = options ?? {};\n\n // TODO V5: remove providerOptions sizeLimit\n if (providerOptionsSizeLimit) {\n if (kbytesToBytes(file.size) > providerOptionsSizeLimit)\n throw new PayloadTooLargeError(\n `${file.name} exceeds size limit of ${bytesToHumanReadable(\n providerOptionsSizeLimit\n )}.`\n );\n } else if (sizeLimit) {\n if (kbytesToBytes(file.size) > sizeLimit)\n throw new PayloadTooLargeError(\n `${file.name} exceeds size limit of ${bytesToHumanReadable(sizeLimit)}.`\n );\n }\n },\n uploadStream(file: File): Promise<void> {\n if (!file.stream) {\n return Promise.reject(new Error('Missing file stream'));\n }\n\n const { stream } = file;\n\n return new Promise((resolve, reject) => {\n pipeline(\n stream,\n fs.createWriteStream(path.join(uploadPath, `${file.hash}${file.ext}`)),\n (err) => {\n if (err) {\n return reject(err);\n }\n\n file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;\n\n resolve();\n }\n );\n });\n },\n upload(file: File): Promise<void> {\n if (!file.buffer) {\n return Promise.reject(new Error('Missing file buffer'));\n }\n\n const { buffer } = file;\n\n return new Promise((resolve, reject) => {\n // write file in public/assets folder\n fs.writeFile(path.join(uploadPath, `${file.hash}${file.ext}`), buffer, (err) => {\n if (err) {\n return reject(err);\n }\n\n file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;\n\n resolve();\n });\n });\n },\n delete(file: File): Promise<string | void> {\n return new Promise((resolve, reject) => {\n const filePath = path.join(uploadPath, `${file.hash}${file.ext}`);\n\n if (!fs.existsSync(filePath)) {\n resolve(\"File doesn't exist\");\n return;\n }\n\n // remove file from public/assets folder\n fs.unlink(filePath, (err) => {\n if (err) {\n return reject(err);\n }\n\n resolve();\n });\n });\n },\n };\n },\n};\n"],"names":["utils","path","fse","stream","pipeline","fs"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { pipeline } from 'stream';\nimport fs, { ReadStream } from 'fs';\nimport path from 'path';\nimport fse from 'fs-extra';\nimport * as utils from '@strapi/utils';\n\n// Needed to load global.strapi without having to put @strapi/types in the regular dependencies\nimport type {} from '@strapi/types';\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\nconst { PayloadTooLargeError } = utils.errors;\nconst { kbytesToBytes, bytesToHumanReadable } = utils.file;\n\nconst UPLOADS_FOLDER_NAME = 'uploads';\n\ninterface InitOptions {\n sizeLimit?: number;\n}\n\ninterface CheckFileSizeOptions {\n sizeLimit?: number;\n}\n\nexport default {\n init({ sizeLimit: providerOptionsSizeLimit }: InitOptions = {}) {\n // TODO V5: remove providerOptions sizeLimit\n if (providerOptionsSizeLimit) {\n process.emitWarning(\n '[deprecated] In future versions, \"sizeLimit\" argument will be ignored from upload.config.providerOptions. Move it to upload.config'\n );\n }\n\n // Ensure uploads folder exists\n const uploadPath = path.resolve(strapi.dirs.static.public, UPLOADS_FOLDER_NAME);\n if (!fse.pathExistsSync(uploadPath)) {\n throw new Error(\n `The upload folder (${uploadPath}) doesn't exist or is not accessible. Please make sure it exists.`\n );\n }\n\n return {\n checkFileSize(file: File, options: CheckFileSizeOptions) {\n const { sizeLimit } = options ?? {};\n\n // TODO V5: remove providerOptions sizeLimit\n if (providerOptionsSizeLimit) {\n if (kbytesToBytes(file.size) > providerOptionsSizeLimit)\n throw new PayloadTooLargeError(\n `${file.name} exceeds size limit of ${bytesToHumanReadable(\n providerOptionsSizeLimit\n )}.`\n );\n } else if (sizeLimit) {\n if (kbytesToBytes(file.size) > sizeLimit)\n throw new PayloadTooLargeError(\n `${file.name} exceeds size limit of ${bytesToHumanReadable(sizeLimit)}.`\n );\n }\n },\n uploadStream(file: File): Promise<void> {\n if (!file.stream) {\n return Promise.reject(new Error('Missing file stream'));\n }\n\n const { stream } = file;\n\n return new Promise((resolve, reject) => {\n pipeline(\n stream,\n fs.createWriteStream(path.join(uploadPath, `${file.hash}${file.ext}`)),\n (err) => {\n if (err) {\n return reject(err);\n }\n\n file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;\n\n resolve();\n }\n );\n });\n },\n upload(file: File): Promise<void> {\n if (!file.buffer) {\n return Promise.reject(new Error('Missing file buffer'));\n }\n\n const { buffer } = file;\n\n return new Promise((resolve, reject) => {\n // write file in public/assets folder\n fs.writeFile(path.join(uploadPath, `${file.hash}${file.ext}`), buffer, (err) => {\n if (err) {\n return reject(err);\n }\n\n file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;\n\n resolve();\n });\n });\n },\n delete(file: File): Promise<string | void> {\n return new Promise((resolve, reject) => {\n const filePath = path.join(uploadPath, `${file.hash}${file.ext}`);\n\n if (!fs.existsSync(filePath)) {\n resolve(\"File doesn't exist\");\n return;\n }\n\n // remove file from public/assets folder\n fs.unlink(filePath, (err) => {\n if (err) {\n return reject(err);\n }\n\n resolve();\n });\n });\n },\n };\n },\n};\n"],"names":["PayloadTooLargeError","utils","errors","kbytesToBytes","bytesToHumanReadable","file","UPLOADS_FOLDER_NAME","init","sizeLimit","providerOptionsSizeLimit","process","emitWarning","uploadPath","path","resolve","strapi","dirs","static","public","fse","pathExistsSync","Error","checkFileSize","options","size","name","uploadStream","stream","Promise","reject","pipeline","fs","createWriteStream","join","hash","ext","err","url","upload","buffer","writeFile","delete","filePath","existsSync","unlink"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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@
|
|
|
1
|
-
import { pipeline } from
|
|
2
|
-
import fs from
|
|
3
|
-
import path from
|
|
4
|
-
import fse from
|
|
5
|
-
import * as utils from
|
|
1
|
+
import { pipeline } from 'stream';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fse from 'fs-extra';
|
|
5
|
+
import * as utils from '@strapi/utils';
|
|
6
|
+
|
|
6
7
|
const { PayloadTooLargeError } = utils.errors;
|
|
7
8
|
const { kbytesToBytes, bytesToHumanReadable } = utils.file;
|
|
8
|
-
const UPLOADS_FOLDER_NAME =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
process.emitWarning(
|
|
13
|
-
'[deprecated] In future versions, "sizeLimit" argument will be ignored from upload.config.providerOptions. Move it to upload.config'
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
const uploadPath = path.resolve(strapi.dirs.static.public, UPLOADS_FOLDER_NAME);
|
|
17
|
-
if (!fse.pathExistsSync(uploadPath)) {
|
|
18
|
-
throw new Error(
|
|
19
|
-
`The upload folder (${uploadPath}) doesn't exist or is not accessible. Please make sure it exists.`
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
checkFileSize(file, options) {
|
|
24
|
-
const { sizeLimit } = options ?? {};
|
|
9
|
+
const UPLOADS_FOLDER_NAME = 'uploads';
|
|
10
|
+
var index = {
|
|
11
|
+
init ({ sizeLimit: providerOptionsSizeLimit } = {}) {
|
|
12
|
+
// TODO V5: remove providerOptions sizeLimit
|
|
25
13
|
if (providerOptionsSizeLimit) {
|
|
26
|
-
|
|
27
|
-
throw new PayloadTooLargeError(
|
|
28
|
-
`${file.name} exceeds size limit of ${bytesToHumanReadable(
|
|
29
|
-
providerOptionsSizeLimit
|
|
30
|
-
)}.`
|
|
31
|
-
);
|
|
32
|
-
} else if (sizeLimit) {
|
|
33
|
-
if (kbytesToBytes(file.size) > sizeLimit)
|
|
34
|
-
throw new PayloadTooLargeError(
|
|
35
|
-
`${file.name} exceeds size limit of ${bytesToHumanReadable(sizeLimit)}.`
|
|
36
|
-
);
|
|
14
|
+
process.emitWarning('[deprecated] In future versions, "sizeLimit" argument will be ignored from upload.config.providerOptions. Move it to upload.config');
|
|
37
15
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
const { stream } = file;
|
|
44
|
-
return new Promise((resolve, reject) => {
|
|
45
|
-
pipeline(
|
|
46
|
-
stream,
|
|
47
|
-
fs.createWriteStream(path.join(uploadPath, `${file.hash}${file.ext}`)),
|
|
48
|
-
(err) => {
|
|
49
|
-
if (err) {
|
|
50
|
-
return reject(err);
|
|
51
|
-
}
|
|
52
|
-
file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;
|
|
53
|
-
resolve();
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
upload(file) {
|
|
59
|
-
if (!file.buffer) {
|
|
60
|
-
return Promise.reject(new Error("Missing file buffer"));
|
|
16
|
+
// Ensure uploads folder exists
|
|
17
|
+
const uploadPath = path.resolve(strapi.dirs.static.public, UPLOADS_FOLDER_NAME);
|
|
18
|
+
if (!fse.pathExistsSync(uploadPath)) {
|
|
19
|
+
throw new Error(`The upload folder (${uploadPath}) doesn't exist or is not accessible. Please make sure it exists.`);
|
|
61
20
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
21
|
+
return {
|
|
22
|
+
checkFileSize (file, options) {
|
|
23
|
+
const { sizeLimit } = options ?? {};
|
|
24
|
+
// TODO V5: remove providerOptions sizeLimit
|
|
25
|
+
if (providerOptionsSizeLimit) {
|
|
26
|
+
if (kbytesToBytes(file.size) > providerOptionsSizeLimit) throw new PayloadTooLargeError(`${file.name} exceeds size limit of ${bytesToHumanReadable(providerOptionsSizeLimit)}.`);
|
|
27
|
+
} else if (sizeLimit) {
|
|
28
|
+
if (kbytesToBytes(file.size) > sizeLimit) throw new PayloadTooLargeError(`${file.name} exceeds size limit of ${bytesToHumanReadable(sizeLimit)}.`);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
uploadStream (file) {
|
|
32
|
+
if (!file.stream) {
|
|
33
|
+
return Promise.reject(new Error('Missing file stream'));
|
|
34
|
+
}
|
|
35
|
+
const { stream } = file;
|
|
36
|
+
return new Promise((resolve, reject)=>{
|
|
37
|
+
pipeline(stream, fs.createWriteStream(path.join(uploadPath, `${file.hash}${file.ext}`)), (err)=>{
|
|
38
|
+
if (err) {
|
|
39
|
+
return reject(err);
|
|
40
|
+
}
|
|
41
|
+
file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;
|
|
42
|
+
resolve();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
upload (file) {
|
|
47
|
+
if (!file.buffer) {
|
|
48
|
+
return Promise.reject(new Error('Missing file buffer'));
|
|
49
|
+
}
|
|
50
|
+
const { buffer } = file;
|
|
51
|
+
return new Promise((resolve, reject)=>{
|
|
52
|
+
// write file in public/assets folder
|
|
53
|
+
fs.writeFile(path.join(uploadPath, `${file.hash}${file.ext}`), buffer, (err)=>{
|
|
54
|
+
if (err) {
|
|
55
|
+
return reject(err);
|
|
56
|
+
}
|
|
57
|
+
file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;
|
|
58
|
+
resolve();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
delete (file) {
|
|
63
|
+
return new Promise((resolve, reject)=>{
|
|
64
|
+
const filePath = path.join(uploadPath, `${file.hash}${file.ext}`);
|
|
65
|
+
if (!fs.existsSync(filePath)) {
|
|
66
|
+
resolve("File doesn't exist");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// remove file from public/assets folder
|
|
70
|
+
fs.unlink(filePath, (err)=>{
|
|
71
|
+
if (err) {
|
|
72
|
+
return reject(err);
|
|
73
|
+
}
|
|
74
|
+
resolve();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
67
77
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
delete(file) {
|
|
74
|
-
return new Promise((resolve, reject) => {
|
|
75
|
-
const filePath = path.join(uploadPath, `${file.hash}${file.ext}`);
|
|
76
|
-
if (!fs.existsSync(filePath)) {
|
|
77
|
-
resolve("File doesn't exist");
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
fs.unlink(filePath, (err) => {
|
|
81
|
-
if (err) {
|
|
82
|
-
return reject(err);
|
|
83
|
-
}
|
|
84
|
-
resolve();
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
export {
|
|
92
|
-
index as default
|
|
78
|
+
};
|
|
79
|
+
}
|
|
93
80
|
};
|
|
81
|
+
|
|
82
|
+
export { index as default };
|
|
94
83
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { pipeline } from 'stream';\nimport fs, { ReadStream } from 'fs';\nimport path from 'path';\nimport fse from 'fs-extra';\nimport * as utils from '@strapi/utils';\n\n// Needed to load global.strapi without having to put @strapi/types in the regular dependencies\nimport type {} from '@strapi/types';\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\nconst { PayloadTooLargeError } = utils.errors;\nconst { kbytesToBytes, bytesToHumanReadable } = utils.file;\n\nconst UPLOADS_FOLDER_NAME = 'uploads';\n\ninterface InitOptions {\n sizeLimit?: number;\n}\n\ninterface CheckFileSizeOptions {\n sizeLimit?: number;\n}\n\nexport default {\n init({ sizeLimit: providerOptionsSizeLimit }: InitOptions = {}) {\n // TODO V5: remove providerOptions sizeLimit\n if (providerOptionsSizeLimit) {\n process.emitWarning(\n '[deprecated] In future versions, \"sizeLimit\" argument will be ignored from upload.config.providerOptions. Move it to upload.config'\n );\n }\n\n // Ensure uploads folder exists\n const uploadPath = path.resolve(strapi.dirs.static.public, UPLOADS_FOLDER_NAME);\n if (!fse.pathExistsSync(uploadPath)) {\n throw new Error(\n `The upload folder (${uploadPath}) doesn't exist or is not accessible. Please make sure it exists.`\n );\n }\n\n return {\n checkFileSize(file: File, options: CheckFileSizeOptions) {\n const { sizeLimit } = options ?? {};\n\n // TODO V5: remove providerOptions sizeLimit\n if (providerOptionsSizeLimit) {\n if (kbytesToBytes(file.size) > providerOptionsSizeLimit)\n throw new PayloadTooLargeError(\n `${file.name} exceeds size limit of ${bytesToHumanReadable(\n providerOptionsSizeLimit\n )}.`\n );\n } else if (sizeLimit) {\n if (kbytesToBytes(file.size) > sizeLimit)\n throw new PayloadTooLargeError(\n `${file.name} exceeds size limit of ${bytesToHumanReadable(sizeLimit)}.`\n );\n }\n },\n uploadStream(file: File): Promise<void> {\n if (!file.stream) {\n return Promise.reject(new Error('Missing file stream'));\n }\n\n const { stream } = file;\n\n return new Promise((resolve, reject) => {\n pipeline(\n stream,\n fs.createWriteStream(path.join(uploadPath, `${file.hash}${file.ext}`)),\n (err) => {\n if (err) {\n return reject(err);\n }\n\n file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;\n\n resolve();\n }\n );\n });\n },\n upload(file: File): Promise<void> {\n if (!file.buffer) {\n return Promise.reject(new Error('Missing file buffer'));\n }\n\n const { buffer } = file;\n\n return new Promise((resolve, reject) => {\n // write file in public/assets folder\n fs.writeFile(path.join(uploadPath, `${file.hash}${file.ext}`), buffer, (err) => {\n if (err) {\n return reject(err);\n }\n\n file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;\n\n resolve();\n });\n });\n },\n delete(file: File): Promise<string | void> {\n return new Promise((resolve, reject) => {\n const filePath = path.join(uploadPath, `${file.hash}${file.ext}`);\n\n if (!fs.existsSync(filePath)) {\n resolve(\"File doesn't exist\");\n return;\n }\n\n // remove file from public/assets folder\n fs.unlink(filePath, (err) => {\n if (err) {\n return reject(err);\n }\n\n resolve();\n });\n });\n },\n };\n },\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { pipeline } from 'stream';\nimport fs, { ReadStream } from 'fs';\nimport path from 'path';\nimport fse from 'fs-extra';\nimport * as utils from '@strapi/utils';\n\n// Needed to load global.strapi without having to put @strapi/types in the regular dependencies\nimport type {} from '@strapi/types';\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\nconst { PayloadTooLargeError } = utils.errors;\nconst { kbytesToBytes, bytesToHumanReadable } = utils.file;\n\nconst UPLOADS_FOLDER_NAME = 'uploads';\n\ninterface InitOptions {\n sizeLimit?: number;\n}\n\ninterface CheckFileSizeOptions {\n sizeLimit?: number;\n}\n\nexport default {\n init({ sizeLimit: providerOptionsSizeLimit }: InitOptions = {}) {\n // TODO V5: remove providerOptions sizeLimit\n if (providerOptionsSizeLimit) {\n process.emitWarning(\n '[deprecated] In future versions, \"sizeLimit\" argument will be ignored from upload.config.providerOptions. Move it to upload.config'\n );\n }\n\n // Ensure uploads folder exists\n const uploadPath = path.resolve(strapi.dirs.static.public, UPLOADS_FOLDER_NAME);\n if (!fse.pathExistsSync(uploadPath)) {\n throw new Error(\n `The upload folder (${uploadPath}) doesn't exist or is not accessible. Please make sure it exists.`\n );\n }\n\n return {\n checkFileSize(file: File, options: CheckFileSizeOptions) {\n const { sizeLimit } = options ?? {};\n\n // TODO V5: remove providerOptions sizeLimit\n if (providerOptionsSizeLimit) {\n if (kbytesToBytes(file.size) > providerOptionsSizeLimit)\n throw new PayloadTooLargeError(\n `${file.name} exceeds size limit of ${bytesToHumanReadable(\n providerOptionsSizeLimit\n )}.`\n );\n } else if (sizeLimit) {\n if (kbytesToBytes(file.size) > sizeLimit)\n throw new PayloadTooLargeError(\n `${file.name} exceeds size limit of ${bytesToHumanReadable(sizeLimit)}.`\n );\n }\n },\n uploadStream(file: File): Promise<void> {\n if (!file.stream) {\n return Promise.reject(new Error('Missing file stream'));\n }\n\n const { stream } = file;\n\n return new Promise((resolve, reject) => {\n pipeline(\n stream,\n fs.createWriteStream(path.join(uploadPath, `${file.hash}${file.ext}`)),\n (err) => {\n if (err) {\n return reject(err);\n }\n\n file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;\n\n resolve();\n }\n );\n });\n },\n upload(file: File): Promise<void> {\n if (!file.buffer) {\n return Promise.reject(new Error('Missing file buffer'));\n }\n\n const { buffer } = file;\n\n return new Promise((resolve, reject) => {\n // write file in public/assets folder\n fs.writeFile(path.join(uploadPath, `${file.hash}${file.ext}`), buffer, (err) => {\n if (err) {\n return reject(err);\n }\n\n file.url = `/${UPLOADS_FOLDER_NAME}/${file.hash}${file.ext}`;\n\n resolve();\n });\n });\n },\n delete(file: File): Promise<string | void> {\n return new Promise((resolve, reject) => {\n const filePath = path.join(uploadPath, `${file.hash}${file.ext}`);\n\n if (!fs.existsSync(filePath)) {\n resolve(\"File doesn't exist\");\n return;\n }\n\n // remove file from public/assets folder\n fs.unlink(filePath, (err) => {\n if (err) {\n return reject(err);\n }\n\n resolve();\n });\n });\n },\n };\n },\n};\n"],"names":["PayloadTooLargeError","utils","errors","kbytesToBytes","bytesToHumanReadable","file","UPLOADS_FOLDER_NAME","init","sizeLimit","providerOptionsSizeLimit","process","emitWarning","uploadPath","path","resolve","strapi","dirs","static","public","fse","pathExistsSync","Error","checkFileSize","options","size","name","uploadStream","stream","Promise","reject","pipeline","fs","createWriteStream","join","hash","ext","err","url","upload","buffer","writeFile","delete","filePath","existsSync","unlink"],"mappings":";;;;;;AA8BA,MAAM,EAAEA,oBAAoB,EAAE,GAAGC,MAAMC,MAAM;AAC7C,MAAM,EAAEC,aAAa,EAAEC,oBAAoB,EAAE,GAAGH,MAAMI,IAAI;AAE1D,MAAMC,mBAAsB,GAAA,SAAA;AAU5B,YAAe;AACbC,IAAAA,IAAAA,CAAAA,CAAK,EAAEC,SAAWC,EAAAA,wBAAwB,EAAe,GAAG,EAAE,EAAA;;AAE5D,QAAA,IAAIA,wBAA0B,EAAA;AAC5BC,YAAAA,OAAAA,CAAQC,WAAW,CACjB,oIAAA,CAAA;AAEJ;;QAGA,MAAMC,UAAAA,GAAaC,IAAKC,CAAAA,OAAO,CAACC,MAAAA,CAAOC,IAAI,CAACC,MAAM,CAACC,MAAM,EAAEZ,mBAAAA,CAAAA;AAC3D,QAAA,IAAI,CAACa,GAAAA,CAAIC,cAAc,CAACR,UAAa,CAAA,EAAA;AACnC,YAAA,MAAM,IAAIS,KACR,CAAA,CAAC,mBAAmB,EAAET,UAAAA,CAAW,iEAAiE,CAAC,CAAA;AAEvG;QAEA,OAAO;YACLU,aAAcjB,CAAAA,CAAAA,IAAU,EAAEkB,OAA6B,EAAA;AACrD,gBAAA,MAAM,EAAEf,SAAS,EAAE,GAAGe,WAAW,EAAC;;AAGlC,gBAAA,IAAId,wBAA0B,EAAA;AAC5B,oBAAA,IAAIN,cAAcE,IAAKmB,CAAAA,IAAI,IAAIf,wBAC7B,EAAA,MAAM,IAAIT,oBACR,CAAA,CAAC,EAAEK,IAAAA,CAAKoB,IAAI,CAAC,uBAAuB,EAAErB,oBACpCK,CAA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AAA,GAAAA;AACnB,wBAAA,IAAIA,GAAK,EAAA;AACP,4BAAA,OAAOP,MAAOO,CAAAA,GAAAA,CAAAA;AAChB;AAEAtB,wBAAAA,OAAAA,EAAAA;AACF,qBAAA,CAAA;AACF,iBAAA,CAAA;AACF;AACF,SAAA;AACF;AACF,CAAE;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/provider-upload-local",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.1",
|
|
4
4
|
"description": "Local provider for strapi upload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"upload",
|
|
@@ -35,25 +35,26 @@
|
|
|
35
35
|
"dist/"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"build": "
|
|
38
|
+
"build": "run -T npm-run-all clean --parallel build:code build:types",
|
|
39
|
+
"build:code": "run -T rollup -c",
|
|
40
|
+
"build:types": "run -T tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
39
41
|
"clean": "run -T rimraf ./dist",
|
|
40
42
|
"lint": "run -T eslint .",
|
|
41
43
|
"test:unit": "run -T jest",
|
|
42
44
|
"test:unit:watch": "run -T jest --watch",
|
|
43
|
-
"watch": "
|
|
45
|
+
"watch": "run -T rollup -c -w"
|
|
44
46
|
},
|
|
45
47
|
"dependencies": {
|
|
46
|
-
"@strapi/utils": "5.
|
|
48
|
+
"@strapi/utils": "5.10.1",
|
|
47
49
|
"fs-extra": "11.2.0"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
|
-
"@strapi/
|
|
51
|
-
"@strapi/types": "5.9.0",
|
|
52
|
+
"@strapi/types": "5.10.1",
|
|
52
53
|
"@types/fs-extra": "11.0.4",
|
|
53
54
|
"@types/jest": "29.5.2",
|
|
54
|
-
"eslint-config-custom": "5.
|
|
55
|
+
"eslint-config-custom": "5.10.1",
|
|
55
56
|
"memfs": "4.6.0",
|
|
56
|
-
"tsconfig": "5.
|
|
57
|
+
"tsconfig": "5.10.1"
|
|
57
58
|
},
|
|
58
59
|
"engines": {
|
|
59
60
|
"node": ">=18.0.0 <=22.x.x",
|