I have created a very simple PHP file that does very simple job, it streams the images from a Silverlight OutOfBrowser application to the server, it mixes between $_GET and $_POST variables, matter of fact here is my very simple code, I am aware of its lack of security but I wrote it anyway just to make sure I can write files over the network and it worked 100% with multiple files uploaded etc.
<?php
//Gets
$myFile = $_GET['FileName'] ? $_GET['FileName'] : "input_stream.txt";
$openedFile = fopen($myFile, 'w') or die("can't open file");
$input = file_get_contents("php://input");
fwrite($openedFile, $input);
fclose($openedFile);
//Check the mime type of the file (WRONG WAY)
$mimeType = mime_content_type($myFile);
$input = null;
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimeType = finfo_file($finfo, $myFile);
echo $myFile . 'was uploaded, mime type : ' . $mimeType;
?>
So is there any simple Ruby alternative to get the raw POST data (which will be a ByteArray from Silverlight)?
You will probably want to use a gem for http access. Here’s one:
https://github.com/jnunemaker/httparty
This example looks like what you need:
https://github.com/jnunemaker/httparty/blob/master/examples/basic.rb