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

mtime and mtime-nsecs multipart headers not sent in browser #2837

Closed
@alanshaw

Description

@alanshaw

The code here essentially is doing the following:

const formData = new FormData()
formData.append(
  'file',
  new Blob([], {type: 'application/octet-stream'}),
  'file/path',
  {header:{mtime:5}}
)

const req = new Request('/test', { method: 'post', body: formData })
await req.text()

Output (tested in Firefox and Chrome):

"-----------------------------227935052110062039083523745638
Content-Disposition: form-data; name=\"file\"; filename=\"file/path\"
Content-Type: application/octet-stream

-----------------------------227935052110062039083523745638--
"

Missing mtime header. Worryingly, as far as I can see, there's no way to set custom multipart headers using the APIs we have in the browser.

The form-data module supports header so it's working in Node.js:

https://github.com/form-data/form-data/blob/d7026253e728af9568503dc3dc55cd1a566605e0/lib/form_data.js#L181-L191

Tests for metadata are skipped here since go-ipfs does not support this feature and the tests that use js-ipfs-http-client in js-ipfs are run from Node.js. This is why we haven't seen failing tests for it.

Maybe we need to test against js-ipfs too, if js-ipfs is going to support features like this before go-ipfs in the future.

I'm not sure how this comment got resolved, I thought I was getting déjà vu! ipfs-inactive/js-ipfs-http-client#1186 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    pkg:http-clientIssues related only to ipfs-http-client

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions