What the reason that I can't convert png url? With jpg works well
const getFileFromUrl = async (url, defaultType = 'image/jpeg') => {
const response = await fetch(url);
const data = await response.blob();
return new File([data], url, {
type: response.headers.get('content-type') || defaultType,
});
};
const pngUrl = 'https://pngimg.com/uploads/smoke/smoke_PNG55226.png';
const jpgUrl = 'picsum.photos/id/930/536/354.jpg';
getFileFromUrl(pngUrl).then(data => console.log(data)).catch(err => console.log(err))
response.headers.get('content-type')doesn't exist. @itwaze: Can you log what is printed byresponse.headers.get('content-type')?