Fix client-to-server transfer by base64 encoding binary buffer
This commit is contained in:
parent
abe4c38571
commit
8ea69dd006
@ -9,6 +9,7 @@ const StreamTake = require('./ws/StreamTake')
|
|||||||
const Socket = require('./ws/Socket')
|
const Socket = require('./ws/Socket')
|
||||||
const { Unit } = require('libflitter')
|
const { Unit } = require('libflitter')
|
||||||
const { NodeDescriptorType } = require('./enum')
|
const { NodeDescriptorType } = require('./enum')
|
||||||
|
const CombinedStream = require('combined-stream')
|
||||||
|
|
||||||
const { Buffer } = require('buffer')
|
const { Buffer } = require('buffer')
|
||||||
const { Readable } = require('stream')
|
const { Readable } = require('stream')
|
||||||
@ -86,10 +87,12 @@ class ServerUnit extends Unit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('write stream', stream)
|
const encoded_buffer = await this._bufferStream(stream)
|
||||||
console.log('write data', { placeholder, position, length })
|
const decoded_buffer = new Buffer(encoded_buffer.toString(), 'base64')
|
||||||
|
|
||||||
stream.pipe(fs.createWriteStream(placeholder.path, { flags: 'r+', start: position }))
|
const combined_stream = CombinedStream.create()
|
||||||
|
combined_stream.append(decoded_buffer)
|
||||||
|
combined_stream.pipe(fs.createWriteStream(placeholder.path, { flags: 'r+', start: position }))
|
||||||
}
|
}
|
||||||
|
|
||||||
_bufferStream(stream) {
|
_bufferStream(stream) {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"author": "Garrett Mills <garrett@glmdev.tech> (https://garrettmills.dev/)",
|
"author": "Garrett Mills <garrett@glmdev.tech> (https://garrettmills.dev/)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"combined-stream": "^1.0.8",
|
||||||
"express-ws": "^4.0.0",
|
"express-ws": "^4.0.0",
|
||||||
"flitter-auth": "^0.19.1",
|
"flitter-auth": "^0.19.1",
|
||||||
"flitter-cli": "^0.16.0",
|
"flitter-cli": "^0.16.0",
|
||||||
|
12
yarn.lock
12
yarn.lock
@ -988,6 +988,13 @@ colors@^1.1.0, colors@^1.3.3:
|
|||||||
resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.3.tgz#39e005d546afe01e01f9c4ca8fa50f686a01205d"
|
resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.3.tgz#39e005d546afe01e01f9c4ca8fa50f686a01205d"
|
||||||
integrity sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==
|
integrity sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==
|
||||||
|
|
||||||
|
combined-stream@^1.0.8:
|
||||||
|
version "1.0.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
|
||||||
|
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
|
||||||
|
dependencies:
|
||||||
|
delayed-stream "~1.0.0"
|
||||||
|
|
||||||
command-line-args@^5.0.2:
|
command-line-args@^5.0.2:
|
||||||
version "5.1.1"
|
version "5.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-5.1.1.tgz#88e793e5bb3ceb30754a86863f0401ac92fd369a"
|
resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-5.1.1.tgz#88e793e5bb3ceb30754a86863f0401ac92fd369a"
|
||||||
@ -1228,6 +1235,11 @@ del@^4.1.0:
|
|||||||
pify "^4.0.1"
|
pify "^4.0.1"
|
||||||
rimraf "^2.6.3"
|
rimraf "^2.6.3"
|
||||||
|
|
||||||
|
delayed-stream@~1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
|
||||||
|
integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk=
|
||||||
|
|
||||||
delegates@^1.0.0:
|
delegates@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
|
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
|
||||||
|
Loading…
Reference in New Issue
Block a user