@opengis/fastify-table 2.0.72 → 2.0.73
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.
|
@@ -11,6 +11,11 @@ interface IFile {
|
|
|
11
11
|
filename?: string;
|
|
12
12
|
ext?: string;
|
|
13
13
|
}
|
|
14
|
-
export default function uploadMultiPart(req: any, { extensions, raw, subdir, originalFilename }?:
|
|
14
|
+
export default function uploadMultiPart(req: any, { extensions, raw, subdir, originalFilename, }?: {
|
|
15
|
+
extensions?: string[];
|
|
16
|
+
raw?: boolean;
|
|
17
|
+
subdir?: string;
|
|
18
|
+
originalFilename?: boolean;
|
|
19
|
+
}): Promise<IFile>;
|
|
15
20
|
export {};
|
|
16
21
|
//# sourceMappingURL=uploadMultiPart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadMultiPart.d.ts","sourceRoot":"","sources":["../../../../server/plugins/file/uploadMultiPart.ts"],"names":[],"mappings":"AAqBA,UAAU,KAAK;IACb,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAyCD,wBAA8B,eAAe,CAC3C,GAAG,EAAE,GAAG,EACR,
|
|
1
|
+
{"version":3,"file":"uploadMultiPart.d.ts","sourceRoot":"","sources":["../../../../server/plugins/file/uploadMultiPart.ts"],"names":[],"mappings":"AAqBA,UAAU,KAAK;IACb,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAyCD,wBAA8B,eAAe,CAC3C,GAAG,EAAE,GAAG,EACR,EACE,UAAU,EACV,GAAG,EACH,MAAM,EACN,gBAAwB,GACzB,GAAE;IACD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACvB,GACL,OAAO,CAAC,KAAK,CAAC,CAuFhB"}
|
|
@@ -36,7 +36,7 @@ async function writeFileToDisk(file, buffer) {
|
|
|
36
36
|
await writeFile(file.filepath, buffer);
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
|
-
export default async function uploadMultiPart(req, { extensions, raw, subdir, originalFilename = false } = {}) {
|
|
39
|
+
export default async function uploadMultiPart(req, { extensions, raw, subdir, originalFilename = false, } = {}) {
|
|
40
40
|
const allowedExtensions = req.routeOptions?.url === "/file/upload-image/*" ? images : all;
|
|
41
41
|
const parts = req.parts();
|
|
42
42
|
// const part = await parts.next();
|
|
@@ -49,11 +49,12 @@ export default async function uploadMultiPart(req, { extensions, raw, subdir, or
|
|
|
49
49
|
throw new Error("upload error");
|
|
50
50
|
}
|
|
51
51
|
const ext = path.extname(value.filename).toLowerCase();
|
|
52
|
-
|
|
52
|
+
// check extension by custom list
|
|
53
|
+
if (extensions && !extensions.includes(ext)) {
|
|
53
54
|
throw new BadRequestError("file extension is not allowed");
|
|
54
55
|
}
|
|
55
|
-
// check extension
|
|
56
|
-
if (!allowedExtensions.includes(ext.substring(1))) {
|
|
56
|
+
// check extension by core list if custom not provided
|
|
57
|
+
if (!extensions && !allowedExtensions.includes(ext.substring(1))) {
|
|
57
58
|
throw new BadRequestError("file extension is not allowed");
|
|
58
59
|
}
|
|
59
60
|
const fileBuffer = await new Promise((res, rej) => {
|