Upload collection of files error "could not store directory"
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: 3works and retrieve a good reference - with any other
Content-Lengthit also works with same reference - without
Content-Lengthit 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"
}
Seems this issue should be on bee rather than beeJs, sorry ;-(
anyway same issue than https://github.com/ethersphere/bee/issues/1882
re-posted to https://github.com/ethersphere/bee/issues/4464
Upstream fixed 🙂