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:
parent
3c19a08d93
commit
b99bde9327
@ -4,7 +4,7 @@ import { DownloadResponse } from '../@types'
|
|||||||
export async function downloadFileBrowser(url: string): Promise<void> {
|
export async function downloadFileBrowser(url: string): Promise<void> {
|
||||||
const headResponse = await fetch(url, { method: 'HEAD' })
|
const headResponse = await fetch(url, { method: 'HEAD' })
|
||||||
const contentHeader = headResponse.headers.get('content-disposition')
|
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()
|
const xhr = new XMLHttpRequest()
|
||||||
xhr.responseType = 'blob'
|
xhr.responseType = 'blob'
|
||||||
xhr.open('GET', url)
|
xhr.open('GET', url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user