Uploaded Image's URL is not included in REST Api response.

Comments

1 comment

  • Avatar
    Eric Pasos

    Hi Kyaw San,

    You will need to convert the response data into string format (see https://cloudinary.com/documentation/upload_images#example_1_upload_multiple_files_using_a_form_unsigned):

    ...
    fetch(url, {
         method: "POST",
         body: formData
    )
    .then((response) => {
         return response.text();
    })
    .then((data) => {
         document.getElementById("data").innerHTML += data;
    });
    ...

    And here is the sample response returned after running the sample code:

    {
    "asset_id":"17714b551826a3f104b6e3a6bce7dbd4",
    "public_id":"docs_uploading_example/test_xwwqif",
    "version":1638755028,"version_id":"49da9c2ddf8b395541295a5c36f24edb",
    "signature":"a488e8762a5f6a5e78c52ad65d157830919a557a",
    "width":864,
    "height":576,
    "format":"jpg",
    "resource_type":"image",
    "created_at":"2021-12-06T01:43:48Z",
    "tags":[],
    "pages":1,
    "bytes":109669,
    "type":"upload",
    "etag":"3e297c2d8da6cb1310727332e862ece4",
    "placeholder":false,
    "url":"http://res.cloudinary.com/demo/image/upload/v1638755028/docs_uploading_example/test_xwwqif.jpg",
    "secure_url":"https://res.cloudinary.com/demo/image/upload/v1638755028/docs_uploading_example/test_xwwqif.jpg",
    "access_mode":"public",
    "context":{},
    "metadata":{"color_id":["color1","color2"],
    "colors_id":["color1","color2"],
    "g0btpgkczvarsmkwli2e":["ojnfizxyivpox6opxspo"],
    "s81oevuzdbvdqq8i6voe":"demo"},
    "existing":false,
    "original_filename":"test"
    }

    Hope this helps. 

    Thanks.

     

    0
    Comment actions Permalink

Please sign in to leave a comment.