使用cloudinary上传多个图像

问题描述 投票:-1回答:1

当我尝试同时上传多张图像时,它会上传同一张图像(首先选择一个图像)两次。

我使用{multiple:1},但仍然无法正常工作。


const uploadToCloudinary = filename =>
  new Promise((resolve, reject) => {
    const publicId = randomize("0", 5);
    // cloudinary.uploader.image_upload_tag(filename, { html: { multiple: 1 } });
    cloudinary.uploader.upload(
      filename,
      {
        html: { multiple: 1 },
        tags: "basic_sample",
        public_id: publicId,
        folder: "vizard",
        eager: [
          {
            width: 200,
            crop: "fit"
          },
          { width: 10, crop: "fit" }
        ]
      },
      (err, image) => {
        if (err) console.warn(err);
        return resolve({
          original: image && image.url,
          w200: image && image.eager[0].url,
          placeholder: image.eager[1].url,
          publicId: image.public_id
        });
      }
    );
  });
node.js graphql cloudinary prisma
1个回答
0
投票

uploadUpload API方法不支持称为html的字段,用于直接上传文件,而不是在其中选择文件的输入字段中创建。

您可能正在寻找的是image_upload_tag或多个文件的jQuery直接上载功能-https://cloudinary.com/documentation/jquery_image_and_video_upload#upload_multiple_images

© www.soinside.com 2019 - 2024. All rights reserved.