Closed jasnell closed 1 year ago
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?
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.
@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 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 limitedFile
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.
@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.
@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.
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
).
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.
File is landing in Node 19: https://github.com/nodejs/node/pull/45139
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.