feat(taildrop): stream files via ReadableStream on send and receive
Send: accept a ReadableStreamDefaultReader instead of a Uint8Array. jsStreamReader (new io.ReadCloser) awaits reader.read() Promises via the channel+FuncOf pattern, feeding chunks directly to the HTTP PUT body. No js.CopyBytesToGo of the full file. Receive: openWaitingFile now returns a pull-based ReadableStream backed by the Go io.ReadCloser (jsReadableStream helper). Each pull call reads up to 64 KiB and enqueues a Uint8Array chunk; no io.ReadAll. jsFileOps.OpenReader: JS now returns a ReadableStream instead of a Uint8Array; Go wraps it in jsStreamReader for streaming delivery. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit was merged in pull request #11.
This commit is contained in:
@@ -281,11 +281,11 @@ func newIPN(jsConfig js.Value) map[string]any {
|
||||
return jsIPN.listFileTargets()
|
||||
}),
|
||||
"sendFile": js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
if len(args) != 3 {
|
||||
log.Printf("Usage: sendFile(stableNodeID, filename, data)")
|
||||
if len(args) != 4 {
|
||||
log.Printf("Usage: sendFile(stableNodeID, filename, stream, declaredSize)")
|
||||
return nil
|
||||
}
|
||||
return jsIPN.sendFile(args[0].String(), args[1].String(), args[2])
|
||||
return jsIPN.sendFile(args[0].String(), args[1].String(), args[2], args[3].Int())
|
||||
}),
|
||||
"waitingFiles": js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
return jsIPN.waitingFiles()
|
||||
|
||||
Reference in New Issue
Block a user