file_size_url
Get file size from URL without downloading it.
0 dependencies.
Returns Promise with 'B', 'KB', 'MB', 'GB', 'TB' on success.
npm i file_size_url
import file_size_url from 'file_size_url';
file_size_url("https://server10.mp3quran.net/bader/Rewayat-Hafs-A-n-Assem/001.mp3")
.then(console.log)
.catch(console.error);
OR
import file_size_url from 'file_size_url';
let size = await file_size_url("https://serverjyy10.mp3quran.net/bader/Rewayat-Hafs-A-n-Assem/0001.mp3")
.catch((error) => console.log(error))
console.log(size)
Example for lop
let array = [
'https://server10.mp3quran.net/bader/Rewayat-Hafs-A-n-Assem/001.mp3',
'https://server10.mp3quran.net/bader/Rewayat-Hafs-A-n-Assem/002.mp3',
'https://server10.mp3quran.net/bader/Rewayat-Hafs-A-n-Assem/003.mp3',
'https://server10.mp3quran.net/bader/Rewayat-Hafs-A-n-Assem/055.mp3',
'https://server10.mp3quran.net/bader/Rewayat-Hafs-A-n-Assem/110.mp3',
]
for (let index = 0; index < array.length; index++) {
try {
let fies_size = await file_size_url(array[index])
if (fies_size.toString().split('.')[0] <= 95 && fies_size.toString().split(' ')[1] === 'MB') {
console.log(fies_size + ' || <= 95 MB');
}
else if (fies_size.toString().split('.')[0] > 95 && fies_size.toString().split(' ')[1] === 'MB') {
console.log(fies_size + ' || > 95 MB');
}
else if (fies_size.toString().split(' ')[1] === 'KB') {
console.log(fies_size + ' || KB');
}
} catch (error) {
console.log(error);
}
}