whatever i'm making rin is terrible

This commit is contained in:
May 2023-12-11 19:53:11 +00:00 committed by GitHub
parent c57f4ed692
commit 79ecb5e408
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -95,6 +95,11 @@ async function pushWebStream(stream: Readable, webStream: ReadableStream) {
return last return last
} }
interface UploadStream {
uploaded: number // number of bytes uploaded
stream : Readable
}
export default class Files { export default class Files {
config: Configuration config: Configuration
api: API api: API
@ -111,9 +116,32 @@ export default class Files {
.catch(console.error) .catch(console.error)
} }
async writeFileStream(metadata: FileUploadSettings) { /**
* @description Start a new message.
* @param streamCount Number of files to upload.
*/
private startMessage(streamCount: number): UploadStream[] {
let streams = []
// can't think of a better way to do
for (let i = 0; i < streamCount; i++) {
streams.push({
uploaded: 0,
stream: new Readable()
})
}
this.api.send(streams.map(e =< e.stream));
return streams
}
writeFileStream(metadata: FileUploadSettings & { size: number }) {
let uploadId = (metadata.uploadId || generateFileId()).toString() let uploadId = (metadata.uploadId || generateFileId()).toString()
let processor = new Promise((resolve, reject) => {
multiAssert( multiAssert(
new Map() new Map()
@ -142,7 +170,18 @@ export default class Files {
) )
) )
})
return {
stream: new Writable({
write(data: any) {
}
}),
processor
}
} }