@opengis/fastify-table 1.4.33 → 1.4.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "1.4.33",
3
+ "version": "1.4.35",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -51,18 +51,20 @@ export default async function uploadMultiPart(req) {
51
51
  const parts = req.parts();
52
52
  const part = await parts.next();
53
53
 
54
- if (!part?.value?.filename) {
54
+ const value = part?.value?.fields?.file || part?.value;
55
+
56
+ if (!value?.filename) {
55
57
  throw new Error('upload error');
56
58
  }
57
59
 
58
- const ext = path.extname(part.value.filename).toLowerCase();
60
+ const ext = path.extname(value.filename).toLowerCase();
59
61
 
60
62
  // check extension
61
63
  if (!allowedExtensions.includes(ext.substring(1))) {
62
64
  throw new Error('file extension is not allowed');
63
65
  }
64
66
 
65
- const buffer = await part.value.toBuffer();
67
+ const buffer = await value.toBuffer();
66
68
 
67
69
  if (!buffer?.length) {
68
70
  throw new Error('file buffer is empty');
@@ -80,11 +82,11 @@ export default async function uploadMultiPart(req) {
80
82
  const newFilename = `${randomUUID()}${ext}`;
81
83
 
82
84
  const file = {
83
- originalFilename: part.value.filename,
85
+ originalFilename: value.filename,
84
86
  filepath: path.join(folder, newFilename).replace(/\\/g, '/'),
85
87
  relativeFilepath: path.join(reldirpath, newFilename).replace(/\\/g, '/'),
86
88
  size: Buffer.byteLength(buffer),
87
- mimetype: part.value.mimetype,
89
+ mimetype: value.mimetype,
88
90
  extension: ext.substring(1),
89
91
  };
90
92
 
@@ -15,7 +15,7 @@ import getTemplate from '../../../plugins/table/funcs/getTemplate.js';
15
15
  import getMeta from '../../../plugins/pg/funcs/getMeta.js';
16
16
  import pgClients from '../../../plugins/pg/pgClients.js';
17
17
  import eventStream from '../../../plugins/util/funcs/eventStream.js';
18
- import getData from '../../table/functions/getData.js';
18
+ import getData from '../../../plugins/table/funcs/getData.js';
19
19
  import getFolder from '../../../plugins/crud/funcs/utils/getFolder.js';
20
20
  import metaFormat from '../../../plugins/table/funcs/metaFormat/index.js';
21
21
 
@@ -63,7 +63,7 @@ export default async function getFile({
63
63
  }
64
64
 
65
65
  const headers = {
66
- 'Content-Disposition': 'inline',
66
+ 'Content-Disposition': `inline; filename=${path.basename(filepath)}`,
67
67
  'Cache-Control': 'max-age=86400',
68
68
  'Content-Type': `${mime(filepath)}`, // ; charset=utf-8 --- untested
69
69
  };