Here is my curl command to download the file. The downloaded file is corrupted and cannot be opened. The file url is https://www.carscoops.com/wp-content/uploads/2022/12/Buick-Encore-GX-Scoop-4.jpg

curl -iv --output abc.jpg --request GET \
  --url https://www.carscoops.com/wp-content/uploads/2022/12/Buick-Encore-GX-Scoop-4.jpg

i even tried with full curl copy from chrome, but it didn't work

curl 'https://www.carscoops.com/wp-content/uploads/2022/12/Buick-Encore-GX-Scoop-4.jpg' --output "abc.jpg" \
  -H 'authority: www.carscoops.com' \
  -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'cache-control: no-cache' \
  -H 'pragma: no-cache' \
  -H 'sec-ch-ua: "Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: document' \
  -H 'sec-fetch-mode: navigate' \
  -H 'sec-fetch-site: none' \
  -H 'sec-fetch-user: ?1' \
  -H 'upgrade-insecure-requests: 1' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36'

it won't work with wget also, but still be accessed via browser, what kind of technique to prevent it from downloading?


1 Answer 1


The images are being Brotli encoded (see the Content-Encoding: br in response header) but your version of curl most likely doesn't have support for brotli so it just silently neglects to decode. You can figure out whether your version of curl supports the returned encoding by adding the --compressed option. If set curl will fail if it does not understand the content-encoding. Example (tested on Debian Buster):

$ curl --compressed "https://www.carscoops.com/wp-content/uploads/2022/12/Buick-Encore-GX-Scoop-4.jpg" > abc.jpg
curl: (61) Unrecognized content encoding type. libcurl understands deflate, gzip content encodings.

Try upgrading your version of curl. Newer builds should support br.

Alternatively there is a brotli command line tool which you can pipe output through to "decompress" (pretty sure the encoding is trivial in the case of already compressed JPEG images so you could actually just strip a few bytes to "decompress" the image, but best to use the right tool for the job ..):

$ curl "https://www.carscoops.com/wp-content/uploads/2022/12/Buick-Encore-GX-Scoop-4.jpg" \
| brotli -d > abc.jpg

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .