-
Notifications
You must be signed in to change notification settings - Fork 97
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
examples: verified CAR file fetcher #577
Conversation
4f713b7
to
1111b82
Compare
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #577 +/- ##
==========================================
- Coverage 60.52% 60.11% -0.42%
==========================================
Files 238 236 -2
Lines 29483 23543 -5940
==========================================
- Hits 17844 14152 -3692
+ Misses 10022 7755 -2267
- Partials 1617 1636 +19
|
7c9f147
to
8e89cad
Compare
8e89cad
to
879dc05
Compare
879dc05
to
e7f12c8
Compare
2036531
to
4bef702
Compare
9c31fee
to
af564b9
Compare
af564b9
to
21682c3
Compare
21682c3
to
5dd05ed
Compare
6c759ea
to
d5d4571
Compare
d5d4571
to
140158c
Compare
@lidel @aschmahmann I'm mesmerised by how short this code snippet is, and it does more than what we had before. It is stupidly simple and works for both regular files and directories. We already had all the necessary pieces in Boxo. No need to be meddling with |
1d8cb34
to
720a4a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @hacdias, hiding all complexity in behind boxo APIs is really nice!
// Fetch the file or directory from the gateway. Since we're using a remote CAR | ||
// backend gateway, this call will internally fetch a CAR file from the remote | ||
// gateway and ensure that all blocks are present and verified. | ||
_, file, err := backend.GetAll(context.Background(), imPath) | ||
if err != nil { | ||
return err | ||
} | ||
defer file.Close() | ||
|
||
// Write the returned UnixFS file or directory to the file system. | ||
return files.WriteTo(file, outputPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 sweet!
5fbb2d1
to
d3384f3
Compare
This adds a simple example on how you can use Boxo to verifiably download a file from a trustless gateway. It does not cover the case where we have directories. I think having this, albeit not supporting directories, is better than nothing. With time, we should convert this into its own library module.
Based on #594 to reuse some code.