1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

Fix download when content disposition header missing (#1680)

* default filenamen

* remove logs
This commit is contained in:
Bogdan Fazakas 2023-01-05 17:40:48 +02:00 committed by GitHub
parent 3c19a08d93
commit b99bde9327
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,7 @@ import { DownloadResponse } from '../@types'
export async function downloadFileBrowser(url: string): Promise<void> {
const headResponse = await fetch(url, { method: 'HEAD' })
const contentHeader = headResponse.headers.get('content-disposition')
const fileName = contentHeader.split('=')[1]
const fileName = contentHeader?.split('=')[1] ? contentHeader?.split('=')[1] : 'file'
const xhr = new XMLHttpRequest()
xhr.responseType = 'blob'
xhr.open('GET', url)