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

Fetch file #1704

Merged
merged 3 commits into from
Mar 19, 2024
Merged

Fetch file #1704

merged 3 commits into from
Mar 19, 2024

Conversation

lastmjs
Copy link
Member

@lastmjs lastmjs commented Mar 11, 2024

This PR implements file:// for fetch from a canister, not from the frontend. It also has example code and tests. This is a very simple version of file://

@bdemann bdemann changed the base branch from main to better_logs March 12, 2024 22:46
@bdemann
Copy link
Member

bdemann commented Mar 12, 2024

What is the feature?

Does it have an issue?

No. Looks like its a bullet point of #1691

What is it doing?

Explanation

Implements fetch file presumably for the frontend since
#1706 is going to take care of the
backend

Questions

  • What do I need to know about the fetch file protocol before I can competently
    preform this review?

Answers?

What is the File protocol?

The file protocol is used to get files on the local file system1. So I would
imagine that on the client side the file protocol would get files on the user's
or developer's computer and on the canister side it would be used to get files
in the canister's file system. So I would expect that on the client side there
isn't much to do besides just pass off to the default implementation of fetch
right?

So presumably fetch with the file protocol on the backend would be used to get
files in the canister's file system.

Considerations

Security restrictions

According to Gemini "Most browsers and environments restrict file protocol
fetching for security reasons. Fetching from arbitrary locations on the user's
device could be a privacy or security risk. Your implementation might need to
consider restrictions or permissions." So in the event that we can't just pass
it off we will have to consider that.

Edge Cases
Non-existent Files

We might have to handle non-existent files gracefully if we can't just use the
default fetch

Permissions

We might have to worry about permissions if we can't just use the default
fetch

In short I hope we can just use the default fetch.

Expectations

Tests

I guess I would expect a front end that is able to get a local file and... do
something with it? Send it to the canister?

Code

Hopefully just hand off to the default implementation of fetch.

Footnotes

  1. Citation Needed

@bdemann
Copy link
Member

bdemann commented Mar 13, 2024

Okay this is definitely a canister side fetch, that's a horse of a different color. Let's start over

@bdemann
Copy link
Member

bdemann commented Mar 13, 2024

Should this be implemented?

I've started reading some stuff about how node fetch doesn't actually implement the file protocol, so we might not should do it either. I'll do some more research including working more with tensor flow to see what exactly it needs the file protocol for and make sure we are understanding its needs correctly.

@lastmjs lastmjs changed the base branch from better_logs to main March 19, 2024 16:52
src/lib/fetch.ts Show resolved Hide resolved
@lastmjs lastmjs merged commit 401b802 into main Mar 19, 2024
119 checks passed
@lastmjs lastmjs deleted the fetch_file branch March 29, 2024 15:33
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.

2 participants