mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-21 21:36:26 -08:00
IT.S DONE FUCK
This commit is contained in:
parent
daca021522
commit
549f7de7ac
|
@ -80,7 +80,7 @@ export class Client {
|
|||
let boundary = "-".repeat(20) + Math.random().toString().slice(2)
|
||||
|
||||
let pushBoundary = (stream: Readable) =>
|
||||
stream.push(`${(file_number++) == 0 ? "" : "\n"}--${boundary}\nContent-Disposition: form-data; name="files[${file_number}]"; filename="${Math.random().toString().slice(2)}\nContent-Type: application/octet-stream\n\n`)
|
||||
stream.push(`${(file_number++) == 0 ? "" : "\r\n"}--${boundary}\r\nContent-Disposition: form-data; name="files[${file_number}]"; filename="${Math.random().toString().slice(2)}\r\nContent-Type: application/octet-stream\r\n\r\n`)
|
||||
let boundPush = (stream: Readable, chunk: Buffer) => {
|
||||
let position = 0
|
||||
console.log(`Chunk length ${chunk.byteLength}`)
|
||||
|
@ -92,8 +92,8 @@ export class Client {
|
|||
}
|
||||
|
||||
let capture = Math.min(
|
||||
this.config.maxDiscordFileSize - (bytes_sent % this.config.maxDiscordFileSize) + 1,
|
||||
chunk.byteLength
|
||||
(this.config.maxDiscordFileSize - (bytes_sent % this.config.maxDiscordFileSize)) + 1,
|
||||
chunk.byteLength-position
|
||||
)
|
||||
console.log(`Capturing ${capture} bytes, ${chunk.subarray(position, position+capture).byteLength}`)
|
||||
stream.push( chunk.subarray(position, position + capture) )
|
||||
|
@ -111,7 +111,7 @@ export class Client {
|
|||
callback()
|
||||
},
|
||||
flush(callback) {
|
||||
this.push(`\n--${boundary}--`)
|
||||
this.push(`\r\n--${boundary}--`)
|
||||
callback()
|
||||
}
|
||||
})
|
||||
|
@ -127,6 +127,11 @@ export class Client {
|
|||
}
|
||||
})
|
||||
|
||||
|
||||
if (!returned.ok) {
|
||||
throw new Error(`[Message creation] ${returned.status} ${returned.statusText}`)
|
||||
}
|
||||
|
||||
let response = (await returned.json() as APIMessage)
|
||||
console.log(JSON.stringify(response, null, 4))
|
||||
return response
|
||||
|
|
|
@ -137,10 +137,10 @@ export class UploadStream extends Writable {
|
|||
|
||||
while (position < data.byteLength) {
|
||||
let capture = Math.min(
|
||||
(this.files.config.maxDiscordFileSize*10) - (this.filled % (this.files.config.maxDiscordFileSize*10)) + 1,
|
||||
data.byteLength
|
||||
((this.files.config.maxDiscordFileSize*10) - (this.filled % (this.files.config.maxDiscordFileSize*10))) + 1,
|
||||
data.byteLength-position
|
||||
)
|
||||
console.log(`Capturing ${capture} bytes from fl, ${data.subarray(position, position + capture).byteLength}`)
|
||||
console.log(`Capturing ${capture} bytes for megachunk, ${data.subarray(position, position + capture).byteLength}`)
|
||||
if (!this.current) await this.getNextStream()
|
||||
if (!this.current) {
|
||||
this.destroy(new Error("getNextStream called during debounce")); return
|
||||
|
@ -491,6 +491,8 @@ export default class Files {
|
|||
return null
|
||||
}
|
||||
|
||||
console.log(msgIdx,position,scanning_chunk.size)
|
||||
|
||||
let headers: HeadersInit =
|
||||
useRanges
|
||||
? {
|
||||
|
|
Loading…
Reference in a new issue