Visiting an IPFS URL with a CID prompts a Save As Download panel from the browser instead of showing the content

When I upload PNG images and PDF files using the IPFS library, I’m able to obtain the CIDs. But, when I visit the IPFS URL using theses CIDs, I don’t see the image or the document, but the browser simply prompts me the Save As Download panel. I’m not sure if this is an indication that the files have not been uploaded properly or not and I also don’t know what’s it’s asking me to download.

I’m currently using Brave for the browser and I don’t think it’s the compatibility with the browser because I’m able to view the IPFS files uploaded by others with no issues like the one from the IPFS website.

Following is one of the CIDs I have created:

https://ipfs.io/ipfs/QmNXd16aqe6a353cshxsuM2YaiX9MRAUp1NB5teornHEMV

Following is how I upload images:

const ipfsClient = require("ipfs-http-client");

const ipfs = ipfsClient({
  host: "ipfs.infura.io",
  port: 5001,
  protocol: "https",
});

app.post('/addImage', (req, res, next) => {
  var form = new multiparty.Form();

  form.parse(req, async function(err, fields, files) {
    const data = fs.readFileSync(files.file[0].path)

    try {
      const added = await ipfs.add(data)
      fs.unlinkSync(files.file[0].path);
      return res.status(200).send({ "ipfs success": added})
    } catch (err) {
      fs.unlinkSync(files.file[0].path);
      return res.status(500).send({ "ipfs error": error})
    }
  })
})

Version
“ipfs-http-client”: “^52.0.4-rc.4”

$ file QmNXd16aqe6a353cshxsuM2YaiX9MRAUp1NB5teornHEMV
QmNXd16aqe6a353cshxsuM2YaiX9MRAUp1NB5teornHEMV: data
$ binwalk QmNXd16aqe6a353cshxsuM2YaiX9MRAUp1NB5teornHEMV 

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
37            0x25            TIFF image data, big-endian, offset of first image directory: 8
20756         0x5114          Copyright string: "Copyright Apple Inc., 2017"

file doesn’t know what it is, binwalk thinks it is a tiff, however gimp wont open it because:

Not a TIFF or MDI file, bad magic number 49091 (0xbfc3)

I belive your file is just corrupted, or at least in a really weird tiff variant that isn’t supported by the browser nor gimp.

@Jorropo Thank you for the prompt response. You were absolutely right. For some reason, uploading to IPFS using the iOS simulators seem to yield unpredictable results because I had no issues with uploading the tiff images on the simulators device before. Using a real device seemed to do the trick.

Btw, in order to use the commands like file or binwalk, are you using the command-line?

I am however file and binwalk are totaly unrelated tools to IPFS, they are tools that try to find what format the file is but havn’t been made with IPFS in mind.
See: