Check if image on remote hosting is valid / correct
Sometimes in your daily work you can meet a problem with an image hosted somewhere in cloud. Knowing whether the image is valid can be very helpful in determining the issue. Here I will show how you can easily obtain this information with well known tool curl.
curl is a popular command-line tool commonly used for transferring data using various network protocols. You can test your REST server when working on some REST API like that
curl -v -XGET <some_api_server>/users/
To get information about image you can use curl with flag -I
curl -I https://img.freepik.com/free-photo/hand-presenting-model-house-home-loan-campaign_53876-104970.jpg?w=1060&t=st=1660223485~exp=1660224085~hmac=bae03c7dde0089b5905f7ff5800d38bbd42d0ed100d3f088d4f45a7d644f82aa
Here we specify flag -l (- -list-only). This command allows to get server response with headers but without the file body.
Output will be like that
Here content-type should have value “image/jpeg”. If content-type value has some value like that “content-type: multipart/form-data; boundary=” the file is broken.