討論 » 開發

How to quickly get remote file size

§
發表於:2020-01-19

How to quickly get remote file size

I'm needing to evaluate online file (image) real size, since HTMLImageElement doesn't contain any relevant property about it I'm forced to make another request by GM_xmlhttpRequest({responseType='blob', ....}) and query response.size to have it. It would be acceptable if it didn't cause performance issues (browser lags unresponsive for about 5-10s for images yet around 10MB, which is too high). I guess the long episode is evaluating response.size. Is there any other method quickly resolving to how many Bs were downloaded instead of counting the buffer elements?

woxxom管理員
§
發表於:2020-01-19
編輯:2020-01-20

No need to fetch the actual contents in most cases. Simply make a method:'HEAD' request, which will only query the server, and extract Content-Length header from response.responseHeaders.

§
發表於:2020-01-27

That's it, thanks

發表回覆

登入以回覆

长期地址
遇到问题?请前往 GitHub 提 Issues。