小编The*_*gyu的帖子

上传前的 Directus v9 文件类型验证

在实际上传之前,有什么方法可以验证或限制可以上传的文件类型/扩展名吗?

我尝试过使用几个自定义挂钩,但它们都刚刚通过。

钩子尝试过:

  • 文件.创建.之前
  • 项目.创建.之前
module.exports = function registerHook({ exceptions }) {
  const { InvalidPayloadException } = exceptions;
  return {
    "files.create.before": async function (input) {
      console.log(input);
      throw new InvalidPayloadException("title");
    },
  };
};
Run Code Online (Sandbox Code Playgroud)

javascript node.js directus

5
推荐指数
1
解决办法
664
查看次数

标签 统计

directus ×1

javascript ×1

node.js ×1