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

问题描述

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

enter image description here

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);
      }
    }
  );

但是,用户仍然可以看到 ALL 类型的文件

enter image description here

解决方法

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