The image I want to download returns 403 when I tried to download with javascript
but I can download image with python code like below. It adds referer to headers and downloads it.
req = urllib.request.Request(image_url, headers={"Referer": referer_url})
with urllib.request.urlopen(req) as response, open("image.jpg", "wb") as outfile:
shutil.copyfileobj(response, outfile)
Is javascript can download image like that ?
Javascript code I am trying with. Its react-native-fetch-blob libaray
export const saveToonImageToLocal = (url, imageName) => {
return RNFetchBlob
.config({
path: dirs.DocumentDir + `${imageName}.jpg`,
appendExt: 'jpg'
})
.fetch('GET', url, {})
.then((res)=>{
return res.path();
})
.catch((e)=>{
console.log('error occurend during saving images');
})
};