Answer the question
In order to leave comments, you need to log in
Is it possible to find out the size of a file, its type, without downloading the whole thing?
Is it possible, using curl, to find out the size of a file from a link (and other information) without downloading the entire file to the server? Is it technically possible. Thanks
Answer the question
In order to leave comments, you need to log in
if the server gives this information, then yes, and if it does not, then no.
Depends on who distributes the files shorter.
Well, infa in the headlines, respectively.
Of course, the first few bytes of the file are unique for each type, and the type can be calculated from them. Thanks to this property, for example, the library works libmagic
.
https://gist.github.com/leommoore/f9e57ba2aa4bf197ebc5
as an option
curl -m 1 -sS -D - -X HEAD https://hsto.org/r/w120/webt/5a/80/fd/5a80fd8c368f0954751429.png 2>/dev/null | grep -Po '(?<=Content-Length: )(\d+)|((?<=Content-Type: )[a-z\-]+/[a-z\-]+)'
image/png
12597
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question