Using rubyamf to write a bytearray to file sent from flex
April 24th, 2009RubyAMF converts a bytearray from AMF to an array of fixnums. Those fixnums represent characters which represent the bytes.
This is how to write the data to file:
1 2 3 4 5 | byteArray = rubyamf_params[2]; #assuming a ByteArray was passed as arg 2 fout = File.open( path, 'wb' ); data = byteArray.pack('c'*byteArray.length); fout.puts(data); fout.close |
Took me a while to figure this out and I didn’t see any instruction elsewhere on the web. I’m currently using this to save images to disk from flex.
July 1st, 2009 at 11:01 am
Thanks Aaron,
That’s exactly what I’ve been looking for.
August 24th, 2009 at 12:36 pm
Hey Aaron,
Thanks, this is half the problem. I still can’t seem to get the fetching side to work either (i.e. reading a byte array from ruby->flex). Do you have a silver bullet for that?
Thanks,
Marty
August 24th, 2009 at 4:29 pm
Marty:
I haven’t actually tried sending back a byte array. I’m sending image data as a byte array to the server then saving the images to disk on the server. The client can then load the images with a url.