Is there a way in Ruby to redirect STDOUT
to an S3Object
? I would like my puts
output to write to my S3Object
. I can do stdout.reopen
but need a filename.
Asked
Active
Viewed 84 times
0

BobDoolittle
- 1,326
- 1
- 12
- 21
-
1http://stackoverflow.com/questions/14987362/how-can-i-capture-stdout-to-a-string – Mircea Oct 09 '15 at 02:05
-
1look at @fearless_fool's answer. – Mircea Oct 09 '15 at 02:06
-
Interesting. So I guess I could buffer all my output to a string that way, and finally write it to S3. I was hoping to write it as I went along so each puts writes incrementally and progress can be monitored. Also to reduce memory buffering size. But this can work for my situation where output isn't enormous, thanks. – BobDoolittle Oct 09 '15 at 15:25
-
1you can also do that if you want :) see http://stackoverflow.com/questions/32801731/rails-how-to-send-file-from-s3-to-remote-server/32833143#32833143 the idea is to use a pipe. attach the write side to the STDOUT and read from reader side :) this way you are actually streaming to S3 – Mircea Oct 09 '15 at 16:27