mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-29 00:46:26 -08:00
whatever i'm making rin is terrible
This commit is contained in:
parent
c57f4ed692
commit
79ecb5e408
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue