I’m trying to download NFT image from IPFS using Infura Api.
Here is my Python code:
get_image_url = ‘https://ipfs.infura.io:5001/api/v0/get?arg={ipfs_path}’
img_path = ‘QmR36VFfo1hH2RAwVs4zVJ5btkopGip5cW7ydY4jUQBrKW’
response = requests.post(get_image_url.format(ipfs_path=img_path), auth=auth)
I expect to receive png image in response content, but in response headers i can see that content-type is text/plain and when saving content bytes to file i get invalid image. I manage to retrieve image from this response by skipping first 512 bytes, but it seems kind of weird (can i depend on that value, is it fixed length header).
When using public gateways (e.g. ‘https://ipfs.infura.io/ipfs/QmR36VFfo1hH2RAwVs4zVJ5btkopGip5cW7ydY4jUQBrKW’) there is no such problem and response content contains only png image.