Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export a version from the writer #161

Closed
achingbrain opened this issue Feb 21, 2024 · 1 comment · Fixed by #162
Closed

Export a version from the writer #161

achingbrain opened this issue Feb 21, 2024 · 1 comment · Fixed by #162

Comments

@achingbrain
Copy link
Member

From what I can tell, this module will only create v1 CAR files and it doesn't provide a method to obtain the version of the file it's creating - please let me know if I've missed something obvious.

When returning a CAR file from an HTTP Gateway the spec says the Content-Type header should include the version number, e.g:

Content-Type: application/vnd.ipld.car; version=1

It'd be great if we could hand that off to the writer, to reduce the chance of it getting messed up, something like:

const { writer, out } = CarWriter.create(cid)

const response = new Response(out, {
  status: 200
})
response.headers.set('content-type', `application/vnd.ipld.car; version=${writer.version()}`)
@rvagg
Copy link
Member

rvagg commented Feb 21, 2024

Yeah, strictly only v1 and as yet I've not seen a compelling reason to do v2 in JS except for if someone wants to make a blockstore; although I think web3.storage has an implementation that uses v2 with indexes for something to do with unixfs paths.

Feel free to add a version field, or a method if you think that makes more sense, it can just return a const 1 for now.

achingbrain added a commit that referenced this issue Feb 21, 2024
The `version()` method retrieves the version number from the
underlying encoder.

Fixes #161
achingbrain added a commit that referenced this issue Feb 22, 2024
The `version()` method retrieves the version number from the
underlying encoder.

Fixes #161
github-actions bot pushed a commit that referenced this issue Feb 22, 2024
## [5.3.0](v5.2.6...v5.3.0) (2024-02-22)

### Features

* add version method to CarWriter ([#162](#162)) ([d1ded7f](d1ded7f)), closes [#161](#161)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants