我创建了一个非常简单的PHP文件,它将图像从Silverlight OutOfBrowser应用程序流式传输到服务器,它混合在$_GET
和$_POST
变量之间,事实上这里是我非常简单的代码,我意识到它缺乏安全感,但我写的也无妨,只是为了确保我可以写的文件在网络上,并将其与上传等多个文件的工作100%什么是“php://输入”的Ruby等价物?
<?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;
?>
那么,有没有简单的Ruby替代,以获得原始POST数据(这将是Silverlight的ByteArray)?
'STDIN'?我认为Ruby比PHP更直接地访问标准输入。 – cHao 2012-04-22 17:21:45