feat(plugin-file-manager): record the creator of the attachment

This commit is contained in:
chenos 2022-05-31 20:17:55 +08:00
parent 9f6e6f22a6
commit a9e1094f8b
2 changed files with 7 additions and 5 deletions

View File

@ -1,10 +1,10 @@
import path from 'path';
import multer from '@koa/multer';
import { Context, Next } from '@nocobase/actions';
import { getStorageConfig } from '../storages';
import * as Rules from '../rules';
import { FILE_FIELD_NAME, LIMIT_FILES, LIMIT_MAX_FILE_SIZE } from '../constants';
import { BelongsToManyRepository, BelongsToRepository } from '@nocobase/database';
import path from 'path';
import { FILE_FIELD_NAME, LIMIT_FILES, LIMIT_MAX_FILE_SIZE } from '../constants';
import * as Rules from '../rules';
import { getStorageConfig } from '../storages';
function getRules(ctx: Context) {
const { resourceField } = ctx;
@ -111,7 +111,7 @@ export async function action(ctx: Context, next: Next) {
const attachment = await ctx.db.sequelize.transaction(async (transaction) => {
// TODO(optimize): 应使用关联 accessors 获取
const result = await storage.createAttachment(data, { transaction });
const result = await storage.createAttachment(data, { context: ctx, transaction });
const { associatedName, associatedIndex, resourceName } = ctx.action.params;
const AssociatedCollection = ctx.db.getCollection(associatedName);

View File

@ -3,6 +3,8 @@ import { CollectionOptions } from '@nocobase/database';
export default {
name: 'attachments',
title: '文件管理器',
createdBy: true,
updatedBy: true,
fields: [
{
comment: '用户文件名(不含扩展名)',