I want to get the size of a file from this path:
my-path/filename
How can I get the size of this file?
I want to get the size of a file from this path:
my-path/filename
How can I get the size of this file?
Use the fetch() method and only set the request method to HEAD.
const fetchResponse = await fetch(src, { method: 'HEAD' });
const size = fetchResponse.headers.get('content-length');
Beware, it will return a number represented as a string.
const size = +fetchResponse.headers.get('content-length');