Cloudinary widget:设置资源类型不限制用户可以上传的文件类型

Cloudinary widget: Setting resource type does not limit the type of files the user can upload

根据 documentation,这是限制用户可以上传的文件类型的方法:

This is how I implemented it in my code:  
  var myWidget = window.cloudinary.createUploadWidget(
    {
      cloudName: "456aefaefaefayrw",
      uploadPreset: "dadazf",
      sources: ["local"],
      resourceType: "image",
    },
    (error, result) => {
      if (!error && result && result.event === "success") {
        console.log("Done! Here is the image info: ", result.info);
      }
    }
  );

但是,用户仍然可以看到 所有 种类型的文件:

Cloudinary 允许将 pdf 作为图像类型上传,而当作为 image 传递时,视频将作为图像上传。您可以在上传小部件中使用 clientAllowedFormats 选项,这将阻止上传除指定格式以外的任何其他格式,或者您可以在上传预设中提及该格式。