Skip to main content

Comments

3 comments

  • Tamara Yulevich

    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:

    https://cloudinary.com/documentation/upload_images#code_explorer_upload_multiple_files_using_a_form_unsigned

    Please let me know if you have any further questions, 

    Tamara

    0
  • Shai Alon

    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,
    Shai

    0
  • Wissam Khalili

    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_ui

    Thanks,

    Wissam

    0

Post is closed for comments.