I dont really understand what your trying to do. You cant create a write
stream without a file name. You could create a random file name and then
rename it once you have the real file name.
On Thursday, March 7, 2013 9:35:00 AM UTC-5, Thorsten Moeller wrote:
>
> Hi,
>
> i am creating a writestre
Hi Tim,
thanks for the hint. Must have overread this. Googled all the time, but
didn't thought about renaming as an approach.
Will try that.
Thanks
Am Donnerstag, 7. März 2013 15:43:43 UTC+1 schrieb Tim Dickinson:
>
> I dont really understand what your trying to do. You cant create a write
>
@tim you're thinking of streams as just file-related things
thorsten -
Using the new stream class you can do:
var stream = new Stream.Readable()
stream.push(null)
stream.push('your data and stuff')
when you're ready for a file
stream.pipe(fs.createWriteStream('outputfile'))
keep in mind data
this approach is good for small data, but with larger files with many
concurrent users this may eat up your memory, because the Stream buffers
the data there. In this case you can just create a Buffer and write it when
done. But i also prefer the tmp-file approach: no buffering and a mv is on
t
This is to say that he is using node 0.9.x
Also as @greelgorke said, a large file will bring up problem with keeping
the data in memory.
Streaming the data to a tmp file "/tnp/random-name" is the best bet.
it removes any complexity that might come up then trying to pipe the data
back into a fil
Security isn't the big thing here as it would be a kind of strictly
internal file distribution between a central server and some other servers
in the same network. No external access here.
The problem i really have is to do some simple filecopy via socket from one
server to another. These are v
well to do this, you have to introduce a protocol how to format the data
sent over tcp. this is what http does. You could use a
JSONStream https://github.com/dominictarr/JSONStream
where you just pipe the it to/from the socket and your json object could be
like: {filename:'a string of file', fil