size of dervied version
Hello!
What is the best approach to get the size of the transformed video, from the client side?
we need to know the exact size of the transform file.
for example-
https://res.cloudinary.com/hcabpjybe/video/upload/w_1224,h_800,c_limit/q_auto:eco/v1659264717/application-assets/g154ctnuul7ezpmpyrv6.mp4
using JS
Is there any way to upload the video transformed, and not the original file?
thanks
-
Hi Shani,
Thanks for contacting us,
You can get details about a specific media asset via our Admin API, specifically using this method but you can't do it from the client side. In the repose, you will get a list of all derived assets of that media asset with information about the derived resource including the size:
for example:
"derived": [ { "transformation": "c_fill,w_100,h_100", "format": "jpg", "bytes": 7112, "id": "8267a869b62a93a59248f35d7f124c1f", "url": "http://.../demo/image/upload/c_fill,w_100,h_100/v1312461204/sample.jpg", "secure_url": "https://.../image/upload/c_fill,w_100,h_100/v1312461204/sample.jpg" }
Yes, you can upload the file as transformed using an unsigned upload preset with the upload method options you want to apply for all files or just a couple of them, here is a code sample:
Please let me know if you have any further questions,
Tamara
0 -
Hi Tamara
Thank you for your reply.
Is there any way to upload the file as transformed via the widget?
Currently, we upload the original file, and then make a request to get the size (in bytes) of transformed URL:
https://res.cloudinary.com/hcabpjybe/image/upload/w_150,h_150,f_auto,c_limit/w_1224,h_800,c_limit/q_auto:eco/v1659509009/application-assets/d5j353ndpgfj5g8wiujp.jpg
const getContentSize = async (url) => {
return new Promise((resolve, reject) => {
request.get(url, {}, (err) => {
if (err) {
return reject(err);
}
request.head(url, {}, (err, res) => {
if (err) {
return reject(err);
}
resolve(res.headers["content-length"]);
});
});
});
};
Can you advise on a better solution?
Regards,
Shai0 -
Hi Shai,
Sorry for the last response.
You could create an upload preset and use it from the media library widget.
This is possible. Please review the following guide:
https://cloudinary.com/documentation/upload_presets#managing_upload_presets_using_the_settings_uiThanks,
Wissam
0
Post is closed for comments.
Comments
3 comments