How to upload an image from cdn url in cloudinary?

Options
Sovik
Sovik Member Posts: 22
edited October 2023 in Developer APIs

The cdn url of the image is given. When I am trying to upload image from cdn it gives filenotfound exception. The code snippet is given below-

Map result = cloudinary.uploader().upload("https://cdn.matchpoint.tv/m2c0rsnksvmfsrmjltky04xvkteihvy9fqnbvydsevbl5ahd2upl60ayiimqw36213g2xpet2rw7rc2q120vpvwictfjpvbtazlkve85zavwvw28il6q3gfbfl15rop1qatyiqxov7idbgk7jbu1gu/1000000006043_157x236.jpg",

ObjectUtils.emptyMap());

System.out.println("result="+result);


output--


Sep 29, 2023 11:16:04 AM org.apache.http.impl.execchain.RetryExec execute

INFO: I/O exception (java.io.FileNotFoundException) caught when processing request to {s}->https://api.cloudinary.com:443: https:\cdn.matchpoint.tv\m2c0rsnksvmfsrmjltky04xvkteihvy9fqnbvydsevbl5ahd2upl60ayiimqw36213g2xpet2rw7rc2q120vpvwictfjpvbtazlkve85zavwvw28il6q3gfbfl15rop1qatyiqxov7idbgk7jbu1gu\1000000006043_157x236.jpg (The filename, directory name, or volume label syntax is incorrect)

Sep 29, 2023 11:16:05 AM org.apache.http.impl.execchain.RetryExec execute

INFO: Retrying request to {s}->https://api.cloudinary.com:443

Sep 29, 2023 11:16:05 AM org.apache.http.impl.execchain.RetryExec execute

INFO: I/O exception (java.io.FileNotFoundException) caught when processing request to {s}->https://api.cloudinary.com:443: https:\cdn.matchpoint.tv\m2c0rsnksvmfsrmjltky04xvkteihvy9fqnbvydsevbl5ahd2upl60ayiimqw36213g2xpet2rw7rc2q120vpvwictfjpvbtazlkve85zavwvw28il6q3gfbfl15rop1qatyiqxov7idbgk7jbu1gu\1000000006043_157x236.jpg (The filename, directory name, or volume label syntax is incorrect)

Sep 29, 2023 11:16:05 AM org.apache.http.impl.execchain.RetryExec execute

INFO: Retrying request to {s}->https://api.cloudinary.com:443

Sep 29, 2023 11:16:06 AM org.apache.http.impl.execchain.RetryExec execute

INFO: I/O exception (java.io.FileNotFoundException) caught when processing request to {s}->https://api.cloudinary.com:443: https:\cdn.matchpoint.tv\m2c0rsnksvmfsrmjltky04xvkteihvy9fqnbvydsevbl5ahd2upl60ayiimqw36213g2xpet2rw7rc2q120vpvwictfjpvbtazlkve85zavwvw28il6q3gfbfl15rop1qatyiqxov7idbgk7jbu1gu\1000000006043_157x236.jpg (The filename, directory name, or volume label syntax is incorrect)

Sep 29, 2023 11:16:06 AM org.apache.http.impl.execchain.RetryExec execute

INFO: Retrying request to {s}->https://api.cloudinary.com:443

java.io.FileNotFoundException: https:\cdn.matchpoint.tv\m2c0rsnksvmfsrmjltky04xvkteihvy9fqnbvydsevbl5ahd2upl60ayiimqw36213g2xpet2rw7rc2q120vpvwictfjpvbtazlkve85zavwvw28il6q3gfbfl15rop1qatyiqxov7idbgk7jbu1gu\1000000006043_157x236.jpg (The filename, directory name, or volume label syntax is incorrect)

at java.io.FileInputStream.open0(Native Method)

at java.io.FileInputStream.open(Unknown Source)

at java.io.FileInputStream.<init>(Unknown Source)

at org.apache.http.entity.mime.content.FileBody.writeTo(FileBody.java:116)

at org.apache.http.entity.mime.AbstractMultipartForm.doWriteTo(AbstractMultipartForm.java:134)

at org.apache.http.entity.mime.AbstractMultipartForm.writeTo(AbstractMultipartForm.java:157)

at org.apache.http.entity.mime.MultipartFormEntity.writeTo(MultipartFormEntity.java:107)

at org.apache.http.impl.DefaultBHttpClientConnection.sendRequestEntity(DefaultBHttpClientConnection.java:158)

at org.apache.http.impl.conn.CPoolProxy.sendRequestEntity(CPoolProxy.java:162)

at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:237)

at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:122)

at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)

at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)

at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)

at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)

at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)

at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)

at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)

at com.cloudinary.http44.UploaderStrategy.callApi(UploaderStrategy.java:133)

at com.cloudinary.Uploader.callApi(Uploader.java:34)

at com.cloudinary.Uploader.upload(Uploader.java:76)

at com.cloudinary.Uploader.upload(Uploader.java:68)

at com.cloudinary.ws.TestAPI.uploadImage(TestAPI.java:33)

at com.cloudinary.ws.TestAPI.main(TestAPI.java:73)

Tagged:

Answers

  • Cloudinary Team
    Cloudinary Team Administrator, Cloudinary Staff Posts: 135 admin
    Options

    Hi there,

    Thanks for reaching out.

    I see in the stack trace you shared that there are slashes in the URL, as seen here:

    https:\cdn.matchpoint.tv\m2c0rsnksvmfsrmjltky04xvkteihvy9fqnbvydsevbl5ahd2upl60ayiimqw36213g2xpet2rw7rc2q120vpvwictfjpvbtazlkve85zavwvw28il6q3gfbfl15rop1qatyiqxov7idbgk7jbu1gu\1000000006043_157x236.jpg
    

    That is not a valid character, so it is throwing an error. Also, I checked our logs for your account and I see that you did successfully upload this file yesterday. So I will assume that you are all set. But if you still have questions or need any assistance, just let us know.

    Kind regards,

    Tia

    Helpful Links For You
    💬 Share questions, connect with other users in our Cloudinary Community forums and Discord server!
    🧑‍🎓 Join our Cloudinary Academy for free courses, workshops and other educational resources.
    📄 Read our documentation for in-depth details on Cloudinary product features and capabilities
    📰 Check out the Cloudinary blog for the latest company news and insights