Re: Write stream to two outputs

2012-10-21 Thread Petar Radosevic
Hi Herwig, Thanks for your help. Herwig Hochleitner writes: (defn copy-multi ([input outputs] (copy-multi input outputs (make-array Byte/TYPE 1024))) ([^java.io.InputStream input outputs buffer] (let [size (.read input buffer)] (when (pos? size) (doseq

Re: Write stream to two outputs

2012-10-21 Thread Herwig Hochleitner
Streaming simultaneously can result in all kinds of problems due differences in speed and reliablility between a disk and network connection. So if you can, buffer the data for the write to S3. Maybe you could just stream to S3 from the file after you've written it? If you must stream

Write stream to two outputs

2012-10-19 Thread Petar Radosevic
Hi, I'm building an app (MIT license) which let's you share files easily without depending on a third party service like CloudApp or Droplr. I'm having the following problem; while uploading the file to your server I want to stream the file directly to S3 and disk. Why both? Because when the

Re: Write stream to two outputs

2012-10-19 Thread Herwig Hochleitner
Sorry, I mistakenly pressed the send shortcut in gmail. The modified-version of io/copy is: (defn copy-multi ([input outputs] (copy-multi input outputs (make-array Byte/TYPE 1024))) ([^java.io.InputStream input outputs buffer] (let [size (.read input buffer)] (when (pos? size)

Re: Write stream to two outputs

2012-10-19 Thread Herwig Hochleitner
The typehint of output should be ^java.io.OutputStream, sorry. Also to your use case: If you don't actually want to stream simultanously, you need to write the data into a buffer and later stream from that. Sorry again for the whopping triple post. -- You received this message because you are