<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Rails StringIO File Upload</title>
	<link>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/</link>
	<description>The Vixiom Blog :: Flex &#38; Flash on Rails</description>
	<pubDate>Thu, 28 Aug 2008 08:42:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
		<item>
		<title>By: Rails and file uploads &#171; 41 technologies</title>
		<link>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-50596</link>
		<dc:creator>Rails and file uploads &#171; 41 technologies</dc:creator>
		<pubDate>Thu, 10 Apr 2008 06:05:47 +0000</pubDate>
		<guid>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-50596</guid>
		<description>[...] http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/ [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] <a href="http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/" rel="nofollow">http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/</a> [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-32523</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Tue, 02 Oct 2007 17:05:04 +0000</pubDate>
		<guid>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-32523</guid>
		<description>Thanks a lot Niels! That's exactly what I needed. I couldn't figure out for the life of me how to deal with small files that come in as StringIO objects.</description>
		<content:encoded><![CDATA[<p>Thanks a lot Niels! That&#8217;s exactly what I needed. I couldn&#8217;t figure out for the life of me how to deal with small files that come in as StringIO objects.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niels</title>
		<link>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-29476</link>
		<dc:creator>Niels</dc:creator>
		<pubDate>Sun, 22 Jul 2007 15:36:46 +0000</pubDate>
		<guid>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-29476</guid>
		<description>It is indeed the case that small files are StringIO objects while larger files get passed as a Tempfile object. This is done for performance reasons (small files can be kept in the buffer since they don't take up too much space there, this saves us from filesystem operations which always carry some overhead (disk seek and the like)).

A universal way to process the uploaded data is:
File.open("your/file/goes/here", "wb") { &#124;f&#124; f.write(params[:your_file_form_field].read) }

No matter whether you are working with a Tempfile or StringIO object, the CGI handler always provides params[:your_file_form_field].original_filename and .content_type for your processing pleasure.</description>
		<content:encoded><![CDATA[<p>It is indeed the case that small files are StringIO objects while larger files get passed as a Tempfile object. This is done for performance reasons (small files can be kept in the buffer since they don&#8217;t take up too much space there, this saves us from filesystem operations which always carry some overhead (disk seek and the like)).</p>
<p>A universal way to process the uploaded data is:<br />
File.open(&#8221;your/file/goes/here&#8221;, &#8220;wb&#8221;) { |f| f.write(params[:your_file_form_field].read) }</p>
<p>No matter whether you are working with a Tempfile or StringIO object, the CGI handler always provides params[:your_file_form_field].original_filename and .content_type for your processing pleasure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-23295</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Wed, 02 May 2007 19:26:31 +0000</pubDate>
		<guid>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-23295</guid>
		<description>Like Bart said, I am having that problem now.  Some files actually come across as StringIO.  I don't know if it is based on the File Type or the Size of the file, but I can't figure out how to get it back as a file object.</description>
		<content:encoded><![CDATA[<p>Like Bart said, I am having that problem now.  Some files actually come across as StringIO.  I don&#8217;t know if it is based on the File Type or the Size of the file, but I can&#8217;t figure out how to get it back as a file object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bart</title>
		<link>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-21092</link>
		<dc:creator>Bart</dc:creator>
		<pubDate>Thu, 15 Mar 2007 05:51:23 +0000</pubDate>
		<guid>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-21092</guid>
		<description>If you're file is small, you get a StringIO object.  So only saving if you don't have StringIO will not save small files.</description>
		<content:encoded><![CDATA[<p>If you&#8217;re file is small, you get a StringIO object.  So only saving if you don&#8217;t have StringIO will not save small files.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chiamingen</title>
		<link>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-19990</link>
		<dc:creator>chiamingen</dc:creator>
		<pubDate>Fri, 23 Feb 2007 06:58:43 +0000</pubDate>
		<guid>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-19990</guid>
		<description>i also encountered the same problem as you, but you could try

@image = Image.create params[:image] unless params[:image][:file_data].size == 0

there are .size method for both StringIO and TempFile, and it return zero if it is empty</description>
		<content:encoded><![CDATA[<p>i also encountered the same problem as you, but you could try</p>
<p>@image = Image.create params[:image] unless params[:image][:file_data].size == 0</p>
<p>there are .size method for both StringIO and TempFile, and it return zero if it is empty</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ira S.</title>
		<link>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-1686</link>
		<dc:creator>ira S.</dc:creator>
		<pubDate>Mon, 04 Dec 2006 02:22:41 +0000</pubDate>
		<guid>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-1686</guid>
		<description>Definitely a big help. I was having trouble getting firefox tell whether a file was really being uploaded, and this was the path...thanks!</description>
		<content:encoded><![CDATA[<p>Definitely a big help. I was having trouble getting firefox tell whether a file was really being uploaded, and this was the path&#8230;thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam T.</title>
		<link>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-1498</link>
		<dc:creator>Adam T.</dc:creator>
		<pubDate>Mon, 27 Nov 2006 05:29:42 +0000</pubDate>
		<guid>http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-1498</guid>
		<description>This post helped me out more than you know.

I'm not sure why file uploading in Rails is such a black-box area filled with weird special cases, but it's nice to know I wasn't the only one with the problem.</description>
		<content:encoded><![CDATA[<p>This post helped me out more than you know.</p>
<p>I&#8217;m not sure why file uploading in Rails is such a black-box area filled with weird special cases, but it&#8217;s nice to know I wasn&#8217;t the only one with the problem.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
