@opengis/fastify-table 2.6.3 → 2.6.6
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/module/core/select/core.user_mentioned.json +3 -0
- package/dist/server/routes/file/controllers/files.d.ts +1 -1
- package/dist/server/routes/file/controllers/files.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/files.js +11 -8
- package/dist/server/routes/table/schema.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../../server/routes/file/controllers/files.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../../server/routes/file/controllers/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAiBvC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAA8B,OAAO,CACnC,EACE,MAAM,EACN,KAAK,EACL,IAAI,GACL,EAAE;IACD,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B,EACD,KAAK,EAAE,YAAY,gBA8DpB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import mime from "../../../plugins/file/providers/mime/index.js";
|
|
3
|
-
// import isFileExists from "../../../plugins/file/isFileExists.js";
|
|
4
3
|
import downloadFile from "../../../plugins/file/downloadFile.js";
|
|
5
4
|
import config from "../../../../config.js";
|
|
6
5
|
import logger from "../../../plugins/logger/getLogger.js";
|
|
@@ -40,10 +39,19 @@ export default async function getFile({ params, query, user, }, reply) {
|
|
|
40
39
|
if (relpath.includes("../")) {
|
|
41
40
|
throw ForbiddenError("invalid characters detected");
|
|
42
41
|
}
|
|
43
|
-
const
|
|
42
|
+
const filepath = path.posix.join("files", relpath);
|
|
43
|
+
const hookData = (await applyHook("preFile", { user, relpath }));
|
|
44
|
+
const headers = {
|
|
45
|
+
"Content-Disposition": `inline; filename=${encodeURIComponent(path.basename(filepath))}`,
|
|
46
|
+
"Cache-Control": "max-age=86400",
|
|
47
|
+
"Content-Type": `${mime(filepath)}`, // ; charset=utf-8 --- untested
|
|
48
|
+
};
|
|
49
|
+
if (hookData?.data) {
|
|
50
|
+
logger.file("file/files", { filepath: params["*"], uid: user?.uid });
|
|
51
|
+
return reply.headers(hookData.headers || headers).send(hookData.data);
|
|
52
|
+
}
|
|
44
53
|
if (hookData)
|
|
45
54
|
return hookData;
|
|
46
|
-
const filepath = path.join("files", relpath);
|
|
47
55
|
if ((config.local || user?.user_type?.includes?.("admin")) && query.debug) {
|
|
48
56
|
const fp = providers();
|
|
49
57
|
const existsS3 = fp.name === "s3"
|
|
@@ -60,11 +68,6 @@ export default async function getFile({ params, query, user, }, reply) {
|
|
|
60
68
|
if (!fileStream) {
|
|
61
69
|
return reply.headers({ "Content-Type": "image/gif" }).send(grayGif);
|
|
62
70
|
}
|
|
63
|
-
const headers = {
|
|
64
|
-
"Content-Disposition": `inline; filename=${encodeURIComponent(path.basename(filepath))}`,
|
|
65
|
-
"Cache-Control": "max-age=86400",
|
|
66
|
-
"Content-Type": `${mime(filepath)}`, // ; charset=utf-8 --- untested
|
|
67
|
-
};
|
|
68
71
|
reply.headers(headers);
|
|
69
72
|
logger.file("file/files", { filepath: params["*"], uid: user?.uid });
|
|
70
73
|
return fileStream;
|