@kne/fastify-file-manager 3.0.6 → 3.0.8

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.
@@ -442,13 +442,13 @@ module.exports = fp(async (fastify, options) => {
442
442
  onRequest: getFolderAuthenticate('write'),
443
443
  schema: {
444
444
  summary: '上传文件到文件夹',
445
- description: '上传文件实体并在 group 中创建文件节点',
445
+ description: '上传文件实体并在 group 中创建文件节点。通过 path 定位目标目录(经 ensurePath 解析/创建;空字符串为根目录)',
446
446
  query: {
447
447
  type: 'object',
448
448
  required: ['type'],
449
449
  properties: {
450
450
  type: { type: 'string', description: '业务域类型' },
451
- parentId: { type: 'string', description: '父文件夹 id' },
451
+ path: { type: 'string', description: '目标文件夹路径(如 a/b/c);空字符串或不传表示根目录' },
452
452
  namespace: { type: 'string', description: '文件命名空间' },
453
453
  language: { type: 'string', description: '语言' }
454
454
  }
@@ -462,7 +462,7 @@ module.exports = fp(async (fastify, options) => {
462
462
  }
463
463
  return await services.folder.upload({
464
464
  type: request.query.type,
465
- parentId: request.query.parentId,
465
+ path: request.query.path,
466
466
  namespace: request.query.namespace,
467
467
  language: request.query.language,
468
468
  file
@@ -253,7 +253,7 @@ module.exports = fp(async (fastify, fastifyOptions) => {
253
253
  return typeof tag.get === 'function' ? tag.get({ plain: true }) : tag;
254
254
  };
255
255
 
256
- const upload = async ({ type, parentId, file, namespace, language, tenantId }) => {
256
+ const upload = async ({ type, path: folderPath = '', file, namespace, language, tenantId }) => {
257
257
  if (!type) {
258
258
  throw new Error('必须传入类型');
259
259
  }
@@ -261,7 +261,8 @@ module.exports = fp(async (fastify, fastifyOptions) => {
261
261
  throw new Error('不能获取到上传文件');
262
262
  }
263
263
 
264
- const targetParentId = parentId || null;
264
+ const targetParentId = await ensurePath({ type, path: folderPath, language, tenantId });
265
+
265
266
  const uniqueName = await allocateUniqueSiblingName({
266
267
  type,
267
268
  parentId: targetParentId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-file-manager",
3
- "version": "3.0.6",
3
+ "version": "3.0.8",
4
4
  "description": "用于管理静态文件上传查看等",
5
5
  "main": "index.js",
6
6
  "scripts": {