-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: Incremental dir upload v2 #745
base: main
Are you sure you want to change the base?
Conversation
Could we do something simplier where we just pipe Currently we pass an array of // BYO stream what yields File(s)
class FileStream extends ReadableStream { /* ... */ }
// We'd build this class and use internally as well with the existing stuff
class UnixFSDirectoryEncoderStream extends TransformStream { /* ... */ }
await new FileStream() // read File(s)
.pipeThrough(new UnixFSDirectoryEncoderStream()) // write File(s), read Blocks
.pipeThrough(new ShardingStream(options)) // write Blocks, read CARs
.pipeThrough(new ShardStoringStream(conf, options)) // write CARs, read CARMeta
.pipeTo(new WritableStream({ write: meta => console.log(meta.cid) })) You have to keep directories open until the end because you don't know when you've finished a directory but that isn't different to what we have now. However, you can write files async and not buffer them in memory. |
@alanshaw I think it is perhaps possible to build something like what you've suggested on top of the API implemented here or some other API that gives you more control. I do not personally like stream piping API as a baseline for the following reasons:
const task = async (writer) => {
const onetxt = writer.createFile(files[0].name)
onetxt.write(new Uint8Array(await files[0].arrayBuffer()))
await onetxt.close()
const twotxt = writer.createFile(files[1].name)
await twotxt.write(new Uint8Array(await files[1].arrayBuffer()))
} It does not concern itself how you obtain files which order or where from nor what representation they are in, which gives you flexibility there. All that said I'm not going to die on this hill, and if you're convinced proposed API is the way to go I'm fine with that too. However that is not type of API I would personally design for the reasons outlined. P.S.: As side note for years (predating react and friends) I have been pursuing FRP and even gave unconf talk about them in first jsconf. Ultimately myself and few others pursuing this came to conclusion that FRP / stream pipelining distracts you from actual business logic and Evan has captured why perfectly in A farewell to frp post. |
I did expect you might say something like that. I'm not wedded to my alternative proposal and what's here will definitely work well. |
No description provided.