bee-js icon indicating copy to clipboard operation
bee-js copied to clipboard

Upload collection of files error "could not store directory"

Open zapaz opened this issue 2 years ago • 2 comments

When uploading collection of files via this API point https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post got this 500 error could not store directory

it seems that it's due to Content-Length required by Bee in each part of the multipart/form-data. That behaviour is not conformant to RFC1867 https://datatracker.ietf.org/doc/html/rfc1867

So API calls are not working with native browser fetch and FormData , and there exists no easy way to add Content-Length this way.

Below is the example :

  • with Content-Length: 3 works and retrieve a good reference
  • with any other Content-Length it also works with same reference
  • without Content-Length it fails , whereas it's RFC1867 conformant

Example

POST http://127.0.0.1:1633/bzz
Content-Type: multipart/form-data; boundary=YTJHJHG465HFG
Swarm-Postage-Batch-Id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

--YTJHJHG465HFG
Content-Disposition: form-data; name="noname";
Content-Type: text/plain
Content-Length: 3

BZZ
--YTJHJHG465HFG--

response with any Content-Length

HTTP/1.1 201 Created
Access-Control-Expose-Headers: Swarm-Tag
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Swarm-Tag: 180
Vary: Accept-Encoding
Date: Sun, 12 Nov 2023 10:35:15 GMT
Content-Length: 93
Connection: close

{
  "reference": "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
}

response without Content-Length

HTTP/1.1 500 Internal Server Error
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Vary: Accept-Encoding
Date: Sun, 12 Nov 2023 10:21:33 GMT
Content-Length: 76
Connection: close

{
  "code": 500,
  "message": "could not store directory"
}

zapaz avatar Nov 12 '23 10:11 zapaz

Seems this issue should be on bee rather than beeJs, sorry ;-(

anyway same issue than https://github.com/ethersphere/bee/issues/1882

zapaz avatar Nov 12 '23 17:11 zapaz

re-posted to https://github.com/ethersphere/bee/issues/4464

zapaz avatar Nov 17 '23 18:11 zapaz

Upstream fixed 🙂

Cafe137 avatar Jul 17 '24 17:07 Cafe137