fix(download): add checkUrlForFile timeout
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m5s
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m5s
Fix #164
This commit is contained in:
parent
32f35ebcca
commit
d00b142231
@ -127,8 +127,15 @@ export const downloadFile = (url: string, filename: string) => {
|
|||||||
*/
|
*/
|
||||||
export const checkUrlForFile = async (url: string) => {
|
export const checkUrlForFile = async (url: string) => {
|
||||||
try {
|
try {
|
||||||
|
const controller = new AbortController()
|
||||||
|
const timeoutId = setTimeout(() => controller.abort(), 2000)
|
||||||
|
|
||||||
// HTTP HEAD request to get headers without downloading the full content
|
// HTTP HEAD request to get headers without downloading the full content
|
||||||
const response = await fetch(url, { method: 'HEAD' })
|
const response = await fetch(url, {
|
||||||
|
method: 'HEAD',
|
||||||
|
signal: controller.signal
|
||||||
|
})
|
||||||
|
clearTimeout(timeoutId)
|
||||||
|
|
||||||
// Check Content-Disposition header
|
// Check Content-Disposition header
|
||||||
const contentDisposition = response.headers.get('content-disposition')
|
const contentDisposition = response.headers.get('content-disposition')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user