I have add a 1024000 bytes file in ipfs ,then when i use
curl “http://localhost:5001/api/v0/get?arg=QmVHzLjYvp4bposJDD2PNeJ9PAFixyQu3oFj6gqipgsukX&output=bin1” to fetch file. I found some
text are in the beginning of data , “QmVHzLjYvp4bposJDD2PNeJ9PAFixyQu3oFj6gqipgsukX0000644000000000000000000372000013114207265017450 0ustar0000000000000000…” and if i use wget to get it ,i found more 1536 byted downloaded, so what happend???
Tested with a different file & confirmed. It seems that the original file is put into a tar archive. (Tested only curl, not wget.)
Here’s the official documentation:
https://ipfs.io/docs/api/#apiv0get
However, it seems that it isn’t working: archive & compress are false by default, and to be sure I’ve added archive=false
and compress=false
, but I’m still getting a tar archive as a result.
Now I am using “github.com/whyrusleeping/tar-utils” package to download file ,everything is ok.
I think the doc need to been updated, or explain the get output more clearly, integrate a 3rd party package sometimes is not a good option
I guess it would be better to fix the API, so that you don’t get a tar archive, unless you input archive=true
.
Use http://localhost:5001/api/v0/cat?arg=QmVHzLjYvp4bposJDD2PNeJ9PAFixyQu3oFj6gqipgsukX
instead if it is just once file.
get
command is used for downloading files and saving them on disk or downloading whole directories.
Still, I don’t really understand. @BooniesFX wants to download and save a file from IPFS, and that’s what both ipfs get
and /api/v0/get
are for, namely to “download IPFS objects”, as it says in the IPFS API docs. So the question is, why get
(via API curl) wraps the object into a tar archive, even if you specifically say archive=false
? This shouldn’t be the case, ergo my assumption that there is a bug.
HTTP API won’t save the file to disk. ipfs get
uses /api/v0/get
do get the files and saves them to disk. What I think happens is that as he specifies filename output=bin1
it sends tar archive with that file being bin1
file.