File argument 'path' is required for 'virtual file' using weird language to form HTTP

I appreciate that this issue has come up in a variety of contexts including:
Here, just about using curl properly.
This that is very close to my issue but basically resolves by saying yes a real path is expected.
Here, a daughter issue of the above requiring a real PATH (we’re so close).
Closest match but I can’t see the resulting HTTP request so I’m not sure what’s being formed and also I don’t think infura will let me use /files

I’m running into this issue presently, trying to form a POST to infura.io to add a file to IPFS using a language called Hoon which is used in a project called Urbit.

I’ve gotten pretty close, but no matter what I do, I can’t seem to get Abspath: /a/path.png to be recognized by the endpoint to allow the upload. Further, when I try to copy headers created by logging the raw output of curl and postman, I don’t even see the Abspath at all in what it produces.

Here’s some documentation of what I’ve tried so far and the results I get from each try..

Any help would be greatly appreciated.

EDIT: note that sometimes I posted to localhost:1090 where I had netcat listening to write to file to get my output so assume that I’m actually pointing at the right endpoint.

EDIT 2: I don’t even have a real filepath as I’m actually grabbing the raw data of a png from another web-generator of pngs to post to IPFS. The eventual goal would be generative creation of content to be posted to IPFS .

I don’t get what is your question ?

I mean, yes all of this is confusing, but I would blame the multipart/form-data specs for being confusing. :slight_smile:
(we could maybe make the docs and error message better ?)

I’m running into this issue presently, trying to form a POST to infura.io to add a file to IPFS using a language called Hoon which is used in a project called Urbit.

I’ve just learnt about that language from you and have no idea how to use it, but you need to create a multipart/form-data with a path param in the form-data.
It seems in most like people try passing the path as a GET parameters while I belive it should be in form-data.

My question is what does the raw HTTP need to look like.

If I understand your answer correctly, I need to pass path, and I think that’s right, but somehow I’m doing it wrong and I can’t quite figure out how.

In this discussion I linked to, they show that parameter as Abspath:, which I have tried a few ways but not had success. Also I can’t see it in what I’ve recorded from Postman and curl when logging the results of what would have otherwise been a successful call to infura and neither of those actually show that ‘header’ where I think it would go, yet, as I say, they are otherwise successful.

Is Abspath wrong? Is it checked somehow for validity? What encoding does it expect?

edit:

It seems in most like people try passing the path as a GET parameters while I belive it should be in form-data .

This is I think where I’m having the issue - I’m trying to code it in there but I lack sufficient information about what that looks like at raw http level.

Abspath is used if you use the filestore.

By default if you add /tmp/example to IPFS, the blocks making /tmp/example are copied into ~/.ipfs/blocks/..., to do that the CLI reads /tmp/example and stream the bytes over the HTTP connection.

If you use the filestore, IPFS’s datastore store the path as well as offset and length kinda like this /tmp/example:123:20 (IPFS blocks are far bigger than 20 bytes, just this is an example).
Then if someone wants to download this file from you, your deamon open /tmp/example and read it from there, that avoid having too copy of /tmp/example stored on your machine.

This is useless if you doesn’t use filestore.

An example

Here some random golang code dealing with the form-data of IPFS add:

1 Like

Ok - I’m not using filestore, I don’t think. Specifically, I don’t need the data to stay up to date against some purported local file.

Using my language, I’m generating this http:

POST / HTTP/1.1
Host: <infura endpoint>
Authorization: Basic <redacted>
Content-Length: 592717

Content-Type: multipart/form-data; boundary=----------------------------------0v2.umn44.gcqjl.9n01c.b9tek.f1na9
Content-Length: 596.290
------------------------------------0v2.umn44.gcqjl.9n01c.b9tek.f1na9
Abspath: /a/path.png
Content-Disposition: form-data; name=''; filename='2022.1.25..01.55.46-dalten-2022%2C01%2C26.png'
Content-Type: image/png

�PNG
<redacted for brevity>
------------------------------------0v2.umn44.gcqjl.9n01c.b9tek.f1na9--

and infura is responding:

'file argument \'path\' is required\0a'

(more verbosely here)

I get the same response back if I exclude Abspath. Also - like I said, I don’t see that in a simple curl or postman call that actually does work so idgi why my version isn’t working. I know this is hard without knowing the specifics of my language, too - thank you for helping me consider my issue.

As it turns out, the issue had something to do w/ encoding and not w/ that path at all. Not sure why it exhibited the way it did, but there we go.

Thank you for your assistance, board and @Jorropo .

EDIT: I am not specifying Abspath: My body looks something like this:

----------------------------a_separator
Content-Disposition: form-data; name="file"; filename="pxArt.png"
Content-Type: image/png

<file data>----------------------------a_separator--
1 Like

Good :slight_smile:
I was not really sure why it was failing, happy to see you suceed.

1 Like