mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-21 21:36:26 -08:00
Working on it...
This commit is contained in:
parent
79ecb5e408
commit
3de215ee35
|
@ -95,9 +95,53 @@ async function pushWebStream(stream: Readable, webStream: ReadableStream) {
|
|||
return last
|
||||
}
|
||||
|
||||
interface UploadStream {
|
||||
namespace StreamHelpers {
|
||||
|
||||
interface UploadStream {
|
||||
uploaded: number // number of bytes uploaded
|
||||
stream : Readable
|
||||
}
|
||||
|
||||
class StreamBuffer {
|
||||
|
||||
readonly targetSize: number
|
||||
filled: number = 0
|
||||
buffer: UploadStream[] = []
|
||||
|
||||
api: API
|
||||
|
||||
constructor( api: API, targetSize: number ) {
|
||||
this.api = api
|
||||
this.targetSize = targetSize
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
async getNextStream() {
|
||||
if (this.buffer[0]) return this.buffer[0]
|
||||
else {
|
||||
// startmessage.... idk
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default class Files {
|
||||
|
@ -116,28 +160,6 @@ export default class Files {
|
|||
.catch(console.error)
|
||||
}
|
||||
|
||||
/**
|
||||
* @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()
|
||||
|
|
Loading…
Reference in a new issue