Download image form blob:http url in Java

Viewed 832

i have images with src blob:https//....

like this :

-enter image description here

to download the image I tested several techniques without results

I tried to load the image like the browser does (http get request)

public static void httpGetImage(String url, String path) {

    //url ==> blob:https://www.colissimo.fr/5e50dd3d-5b7f-4861-b0ec-34e12f4f3af4

    try {
        HttpGet get = new HttpGet(url);
        get.addHeader("content-type", "image/png");

        try (CloseableHttpClient httpClient = HttpClients.createDefault();
                CloseableHttpResponse response = httpClient.execute(get)) {

            HttpEntity entity = response.getEntity();
            if (entity != null) {
                try (FileOutputStream outstream = new FileOutputStream(new File(path))) {
                    entity.writeTo(outstream);
                }
            }
            httpClient.close();
        }

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

I get this error :

org.apache.http.client.ClientProtocolException: URI does not specify avalid host name:blob:https://www.colissimo.fr/5f67d9be-43bb-489d-8746-cf8fccf2cac9
0 Answers
Related