New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add with nocopy is still requiring path argument #5984
Comments
|
in the normal (non-filestore) case, the meaning of "argument" is that the file is POSTed in the form body (this can definitely be phrased a lot better) EDIT: hmm ok yeah the behavior of I'm not entirely sure how the HTTP API works with filestore, even conceptually, given that you may not have any insight into the filesystem that the daemon operates on |
|
The filestore case is the same as the normal add case (send a bunch of files as a multipart mime body) except that, instead of actually copying the data, we insert a filestore reference. I believe (?) the motivation here is that it allows renaming. That is, the names of the files/directories added to go-ipfs don't need to match those on the filesystem. |
|
@Stebalien how does the reference know where on the filesystem the actual blocks reside? if we're just posting a multipart form with bytes it doesn't have the file metadata |
|
ohh I see, you specify the path and send the file separately: $ echo "filez" > test
$ curl 'http://127.0.0.1:5001/api/v0/add?nocopy=true&arg=test' -F file=@test
{"Name":"test","Hash":"zb2rhmqiJJ7fpnwE1p6F6khKSrmTrVVN2CZBtVB3B4K9Cpdx2","Size":"6"}
$ ipfs cat zb2rhmqiJJ7fpnwE1p6F6khKSrmTrVVN2CZBtVB3B4K9Cpdx2
filezis that right? |
|
Almost. It takes file arguments so these aren't specified in the URL parameters. To specify the path, you actually need to set an I think the right approach is: |
|
ahh ok this isn't really well documented -- I'm going to PR the HTTP API repo |
|
@Stebalien hmm getting this with 0.4.18: EDIT: the correct way to set the header with curl is
EDIT2: but wait, this is a custom header inside the multipart form fragment... I don't know how to set those |
|
using custom headers inside multipart forms is illegal (https://tools.ietf.org/html/rfc7578#section-4.8), which means this approach will not be supported by HTTP client libraries EDIT: actually only old client libs, see below! |
That seems to affect only |
Unfortunately, I'm pretty sure those docs are auto-generated. I'm not sure what the right approach is.
You're missing a |
As noted in #4558 (comment), this is the case:
|
|
could you show me the output from your curl with |
(There is another valid example in #4558 (comment)) |
|
For |
|
yes ok it seems that 7.47 (latest that this machine/Ubuntu 16.04 LTS has, sadly) quietly does not support this, sadly I can't find the corresponding fix in curl changelogs would probably prefer "X-IPFS-FilestorePath" or the like but I guess it's easier this way because it matches the FileInfo property? @hsanjuan is there a reasonably painless way to add this to the API docs? happy to get it nicely written up if there's a way to add an override |
|
found it, looks like > 7.57 is what you need for custom form headers the interesting thing is that this seems to be aimed at MIME mail messages but also happens to work for our use case they also seem to be in favor of the X-... convention |
|
And of course, the issue isn't using Curl. Curl is just for testing, the reason for doing this is going to be for example inside Javascript, where its going to be **** hard to construct this weird query in JS, to set an inner custom header on a multipart mime. I', womdering why the Http-api Note @parkan this is no longer urgent for me though I think its a "design bug", I gave up on filestore (between this and the problem with not liking cross-filesystem paths) and switched to urlstore for what I needed. |
|
@mitra42 given that filestore is still considered experimental, it makes sense that the interface is patterned after the normal add (which, sensibly, makes no assumptions about the filesystem) I expect future API versions (like ipfsx) to have a cleaner approach based on these learnings will close this for now (though I'm still hoping to clear up the existing API docs a bit) |
mitra42 commentedFeb 11, 2019
•
edited
Version information:
go-ipfs version: 0.4.18-
Repo version: 7
System version: amd64/darwin
Golang version: go1.11.1
Type: bug ?
Description:
URLs like
http://127.0.0.1:5001/api/v0/add?nocopy=true&arg=/Users/mitra/temp/archiveorg/commute/commute.mp4Are failing with
File argument 'path' is requiredThe docs unfortunately appear to be buggy [https://docs.ipfs.io/reference/api/http/#api-v0-add] says there is a required arg= parameter, but the curl example omits that, so I'm not sure to trust the docs, but it also says.
Argument “path” is of file type. This endpoint expects a file in the body of the request as ‘multipart/form-data’.which is unclear, but suggests it needs the contents of the file supplied inline.Apart from the bug in the docs (missing
argfrom example, or erroneously specified as a required argument), I think there is a bug where even if the path is supplied to arg=, and nocopy is provided, then it is still expecting content inline.Its possible I'm misreading something, but there seem to be no examples anywhere surfacable with google of the HTTP API being used to add an url to filestore with nocopy=true
The text was updated successfully, but these errors were encountered: