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

Blob and File #17

Closed
jasnell opened this issue Jun 1, 2022 · 9 comments · Fixed by #19
Closed

Blob and File #17

jasnell opened this issue Jun 1, 2022 · 9 comments · Fixed by #19

Comments

@jasnell
Copy link
Contributor

jasnell commented Jun 1, 2022

Node.js, Deno, and Cloudflare Workers all provide implementations of Blob.

Deno and Workers provide implementations of File.

These should likely be included in the minimum common api.

@legendecas
Copy link
Member

How is Deno and Cloudflare workers' implementation of File going to interoperate with platform APIs? AFAICT, Deno's file operations are based on Deno.FsFile, which is not a File interface. I didn't find any manuals on the Cloudflare Workers website about File.

On the web platform, the File interface is primarily used with the <input> element and the HTML drag and drop API. Both of which I failed to see the use cases on the Deno and CF workers.

Would you mind elaborating on the File implementation and its platform integration?

@Tseian
Copy link

Tseian commented Jul 8, 2022

In Bytedance, Hourai.js support File and Blob according to W3C File API spec.
File is a Blob which has a special Symbol.toStringTag name "File" and some other properties.

@legendecas
Copy link
Member

@Tseian that's great to know. Would you mind sharing how the File interface is integrated into your platform? As I said above, I didn't find there are signals that the very limited File interface is being used in the wild other than in browsers. It would be great to know how common the usage is of the API in the server-side runtimes.

@Tseian
Copy link

Tseian commented Jul 11, 2022

@Tseian that's great to know. Would you mind sharing how the File interface is integrated into your platform? As I said above, I didn't find there are signals that the very limited File interface is being used in the wild other than in browsers. It would be great to know how common the usage is of the API in the server-side runtimes.

We use File in Fetch API to make Fetch API can upload data to remote server as aFile or download File data from remote server. Maybe there are some other usage we have not found.

@legendecas
Copy link
Member

@Tseian thank you for your sharing. IIUC, we can receive a Blob from Response in fetch or send blobs as the body with Request. I may miss a point here, but, how do you create a File from a Response, is that an extension that is not part of the fetch spec in your implementation? For a generic HTTP request and response, I may not see how to construct a File with the necessary part like file name, type, and lastModified.

@Tseian
Copy link

Tseian commented Jul 11, 2022

@legendecas I just read some implementation code. I have made a mistake, the File just is used in FormData for uploading data to remote server. There is no extension. Yes, after some thoughts, I agree with you on "I may not see how to construct a File with the necessary part like file name, type, and lastModified.". Name, type and lastModified in the Blob instance that come from remote server that is really look like no sense.

@lucacasonato
Copy link
Member

AFAICT, Deno's file operations are based on Deno.FsFile, which is not a File interface.

No, our File global is not the same as Deno.FsFile, but rather the web standard File. We used to have a Deno.File, but deprecated this due to the naming confusion (it is now Deno.FsFile).

@sashafirsov
Copy link

sashafirsov commented Oct 1, 2022

The W3C File API spec File concept as a Blob operations does not fit into limitations of embedded environments where RAM is limited resource.

Rather embedded environments would gain on file API for random access, streaming, pipeline processing, memory mapping. All currently supported by most of OS, some embedded. I have not seen proposals on such essential needs in the W3C community groups yet,

anyone dare to penetrate this gap?

Disclaimer: the streaming and pipeline exist but not tied to W3C File. Node.js fs streaming does not count.

@Ethan-Arrowood
Copy link
Contributor

File is landing in Node 19: nodejs/node#45139

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.

6 participants