Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

go-ipfs-api cant add file via http #30

@slothbag

Description

@slothbag

First request to IPFS using curl works
curl -i -H "Content-Type: multipart/form-data; boundary=CUSTOM" -d $'--CUSTOM\r\nContent-Type: multipart/octet-stream\r\nContent-Disposition: file; filename="test"\r\n\r\nHello World!\n--CUSTOM--' "http://1.1.1.1:5001/api/v0/add?encoding=json&stream-channels=true"

Send

POST /api/v0/add?encoding=json&stream-channels=true HTTP/1.1
Host: 1.1.1.1:5001
User-Agent: curl/7.43.0
Accept: */*
Content-Type: multipart/form-data; boundary=CUSTOM
Content-Length: 117

--CUSTOM
Content-Type: multipart/octet-stream
Content-Disposition: file; filename="test"

Hello World!
--CUSTOM--

Result

{"Name":"test","Hash":"QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG"}

Sending request using go-ipfs-api

POST /api/v0/add?encoding=json&stream-channels=true HTTP/1.1
Host: 1.1.1.1:5001
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Content-Disposition: form-data: name="files"
Content-Type: multipart/form-data; boundary=04f67da35c831a08306078cd32c7bac8f906018e58c2bdbe56d05323a1b9
Accept-Encoding: gzip
Connection: close

1
-
a3
-04f67da35c831a08306078cd32c7bac8f906018e58c2bdbe56d05323a1b9
Content-Type: application/octet-stream
Content-Disposition: form-data; name="file"; filename=""


8000
<lots of binary data>

--04f67da35c831a08306078cd32c7bac8f906018e58c2bdbe56d05323a1b9--

0

Result

{"Name":"","Bytes":61252}
{"Name":"QmcLpF3adjhfBZMo6yxSNfYMfaPDbVxVTA3Hv3cAqTEc6i","Hash":"QmcLpF3adjhfBZMo6yxSNfYMfaPDbVxVTA3Hv3cAqTEc6i"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions