Retrive docx and ppt via HTTP returns zip file

I am uploading all kinds of files like .ppt,.pdf,.jpg,.docx etc to ipfs. And I am able to get the PDF images properly but for docx and ppt zipped folder is downloading. Can anyone help me with this please. Link I am using is

1 Like

When adding the files to IPFS, try adding the --wrap-with-directory flag to your command, so IPFS wraps your file in a directory and you keep the file extension.

This way, when downloading, you’ll use the link http://:9393/ipfs/hash/filename.docx and the file extension is kept intact, so your OS/Browser knows how to handle the file.

With go-ipfs, the command would be something like this:

$ ipfs add --wrap-with-directory mydocument.docx
added Qmami5EChMsYd4ATBGR8A5bpjcBzzzy4e3XR9fsSC3HUjt mydocument.docx
added QmSpJVvYRjktDVXr8XabDWAsWC1qabP6HZGwUQrDvzKPub

Then use the second hash + filename to retrieve it

FYI: updated the topic to be more descriptive.


Dir-wrapping isn’t necessary with all formats, but probably recommended, because if the browser doesn’t recognize the format, it’ll just download the file as plain data, so the recipient must know beforehand, what kind of format he’ll be downloading.

The main reason in this case is that docx is in fact a zipped directory which is just called “docx” by Microsoft convention. (You can run unzip etc. on files like docx.) Therefore, if you don’t dir-wrap the docx-ipfs-object, it will be returned as a zip, because that’s what the browser is probably getting from the file header.