-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use big file downloader (#180)
This PR uses `@storacha/unixfs-dl` to make ranged requests to big unixfs files in order to not exhaust the upstream worker of CPU time. Also switches to using the `Link` type for CIDs instead of `string`. This allows us to detect if the CID is using the "raw" IPLD codec.
- Loading branch information
Alan Shaw
authored
Sep 25, 2024
1 parent
db444e0
commit 57832cc
Showing
13 changed files
with
290 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Determine if the request is for a specific byte range. | ||
* @param {Headers} headers | ||
*/ | ||
export const isRangeRequest = headers => headers.get('Range') !== null | ||
|
||
/** | ||
* Determine if the request is for an alternative format, like an IPLD block or | ||
* a CAR file. | ||
* @param {Headers} headers | ||
* @param {URLSearchParams} searchParams | ||
*/ | ||
export const isAlternateFormatRequest = (headers, searchParams) => { | ||
const format = searchParams.get('format') | ||
const accept = headers.get('Accept') | ||
return Boolean(format || accept?.includes('application/vnd.ipld.')) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.