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

feat: add blob handler #100

Closed
wants to merge 1 commit into from
Closed

feat: add blob handler #100

wants to merge 1 commit into from

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented May 2, 2024

Adds GET/blob/:multihash

refs storacha/w3infra#363

Copy link

@Gozala Gozala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, although I do wonder if we should instead overload raw block read interface instead of adding another dependency on carpark

export function withBlobHandler (handler) {
return async (request, env, ctx) => {
const url = new URL(request.url)
if (!url.pathname.startsWith('/blob/')) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need the /blob/ interface as in is there reason why we would not use RAW cid handler instead ? If we did query content claims for raw blocks we would effectively get pointer to the file covering it's full content would not we ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, lets move this into the raw handler.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I also agree, and think actually having /blob will just make everything more complicated on the reads side

alanshaw pushed a commit to storacha/dagula that referenced this pull request May 14, 2024
This PR adds a `streamBlock(cid, [options])` method to Dagula that
returns a `ReadableStream` of block bytes. You can optionally pass a
byte range to extract a subset of bytes.

Also `statBlock(cid, [options])` that retrieves block info i.e. total
size in bytes.

The idea is to allow dagula to serve byte ranges from big blocks without
having to load the whole thing into memory.

BREAKING CHANGE: The `Blockstore` interface now includes a `stream`
method that returns a `ReadableStream` and a `stat` method that returns
info (byte size).

The format for the `entityBytes` option of `getPath` has changed. It is
now an array of 1 or 2 numbers. See `Range` type for more details.

refs
storacha/freeway#100 (comment)
alanshaw pushed a commit to storacha/gateway-lib that referenced this pull request May 14, 2024
Supports byte ranges for raw block requests - including multipart.

depends on storacha/dagula#44

refs storacha/freeway#100 (comment)

BREAKING CHANGE: dependencies for handlers have changed, splitting out block, DAG and unixfs services. These are all satisfied by the `Dagula` class for the time being.
alanshaw pushed a commit that referenced this pull request May 15, 2024
Pulls in latest gateway-lib and dagula to allow byte range requests to
raw blocks (`?format=raw`).

supersedes #100
@alanshaw alanshaw closed this May 15, 2024
@alanshaw alanshaw deleted the feat/blob-handler branch May 15, 2024 10:06
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 this pull request may close these issues.

3 participants