mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 15:44:59 +00:00
Merge pull request #17159 from goodhoko/chunk-conditionally
This commit is contained in:
commit
961ad56e43
@ -42,7 +42,17 @@ export = {
|
||||
config.folder = file.path;
|
||||
}
|
||||
|
||||
const uploadStream = cloudinary.uploader.upload_chunked_stream(
|
||||
// For files smaller than 99 MB use regular upload as it tends to be faster
|
||||
// and fallback to chunked upload for larger files as that's required by Cloudinary.
|
||||
// https://support.cloudinary.com/hc/en-us/community/posts/360009586100-Upload-movie-video-with-large-size?page=1#community_comment_360002140099
|
||||
// The Cloudinary's max limit for regular upload is actually 100 MB but add some headroom
|
||||
// for size counting shenanigans. (Strapi provides the size in kilobytes rounded to two decimal places here).
|
||||
const uploadMethod =
|
||||
file.size && file.size < 1000 * 99
|
||||
? cloudinary.uploader.upload_stream
|
||||
: cloudinary.uploader.upload_chunked_stream;
|
||||
|
||||
const uploadStream = uploadMethod(
|
||||
{ ...config, ...customConfig },
|
||||
(err, image) => {
|
||||
if (err) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user