VerdeCircle / strapi-provider-upload-cloudinary-folderoptions

an extension of the strapi-provider-upload-cloudinary that allows for a default_folder option in the config as well as using the file name to define folder structure.
https://www.npmjs.com/package/strapi-provider-upload-cloudinary-folderoptions
Other
12 stars 3 forks source link

support for eager async preview urls (big videos) #4

Open cjm771 opened 2 years ago

cjm771 commented 2 years ago

Hi awesome tool! i love it. realized for large videos preview url gif you try to generate gets 400'd due to automatic on the fly generation only works for file sizes 40mb and below. need to supply eager_async: true, so adding this slight change to your code would support it:

In the code put

if (image.resource_type === 'video') {
  if (image.eager?.length) {
    file.previewUrl = image.eager[0].secure_url;
  } else {
    file.previewUrl = cloudinary.url(`${image.public_id}.gif`, {
      video_sampling: 6,
      delay: 200,
      width: 250,
      crop: 'scale',
      resource_type: 'video',
    });
  }
}

example setting:

    actionOptions: {
          upload: {
            eager: [
              { video_sampling: 6,
                delay: 200,
                width: 250,
                crop: 'scale',
                resource_type: 'video',
                fetch_format: 'gif',
                format: 'gif',
              }
            ],
            eager_async: true,
          },
        }
      },