jasontbradshaw / tailing-stream Goto Github PK
View Code? Open in Web Editor NEWA Node.js module that can read a growing file continuously as a Stream.
License: MIT License
A Node.js module that can read a growing file continuously as a Stream.
License: MIT License
I'm receiving a stream via socket.io.-stream then saving it. I need this module to read the the file which is continuously growing and then push to box.com. Your readme didn't include any example. Can you please show me how this can be done?
io.on('connection', socket => {
console.log('connection');
ss(socket).on('file', (stream, data) => {
console.log('>>>Received File Emit at <<<', new Date().toString());
console.log('data.originalName', data.originalName);
var streamFileName = './uploads/'+data.originalName;
stream.pipe(fs.createWriteStream( streamFileName ));
var boxStream = ts.TailingReadableStream (path.join(__dirname, streamFileName),{timeout: 5000});
function requestCallback(err, res, body) {
console.log('Request body: ',body);
}
var total = 0;
boxStream.on('data', (chunk) => {
total += chunk.length;
var progress = (1.0 * total) / data.size;
console.log('Box upload progres : ', progress);
});
var accessToken = 'hidden';
var parent_folder_id = 'hidden';
var r = request.post({
url: 'https://upload.box.com/api/2.0/files/content',
headers: { 'Authorization': 'Bearer ' + accessToken }
}, requestCallback);
var form = r.form();
form.append('parent_id', parent_folder_id);
form.append("file", boxStream);
});
});
Does this module account for input files that are sliced or rolled while they are being tailed?
I'm trying to use this module with a pipe but it throws an error about an unimplemented method:
Error [ERR_METHOD_NOT_IMPLEMENTED]: The _read() method is not implemented
at TailingReadableStream.Readable._read (_stream_readable.js:611:24)
at TailingReadableStream.Readable.read (_stream_readable.js:457:10)
at flow (_stream_readable.js:957:34)
at Mp4Frag.pipeOnDrainFunctionResult (_stream_readable.js:761:7)
at Mp4Frag.emit (events.js:198:13)
at onwriteDrain (_stream_writable.js:495:12)
at afterWrite (_stream_writable.js:483:5)
at process._tickCallback (internal/process/next_tick.js:63:19
I see from the state of other tickets that this module is unmaintained, but at least this ticket will help others finding that the module is no longer compatible with the ReadableStream API to understand that they will need to find another module or write their own solution.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.