<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Rails StringIO File Upload</title>
	<atom:link href="http://blog.alastairdawson.com/2006/07/26/rails-stringio-file-upload/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.alastairdawson.com/2006/07/26/rails-stringio-file-upload/</link>
	<description>Flex, Ruby, etc. etc.</description>
	<lastBuildDate>Sat, 06 Feb 2010 21:14:13 -0800</lastBuildDate>
	
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Daniel</title>
		<link>http://blog.alastairdawson.com/2006/07/26/rails-stringio-file-upload/comment-page-1/#comment-31</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Thu, 26 Feb 2009 23:41:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-31</guid>
		<description>Thanks a lot.
What i had to add was a nil check, cause it throwed an exception when accessing the &#039;size&#039; property.

params[:image][:file_data].nil?

cheers

daniel</description>
		<content:encoded><![CDATA[<p>Thanks a lot.<br />
What i had to add was a nil check, cause it throwed an exception when accessing the &#8217;size&#8217; property.</p>
<p>params[:image][:file_data].nil?</p>
<p>cheers</p>
<p>daniel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rails and file uploads &#171; 41 technologies</title>
		<link>http://blog.alastairdawson.com/2006/07/26/rails-stringio-file-upload/comment-page-1/#comment-30</link>
		<dc:creator>Rails and file uploads &#171; 41 technologies</dc:creator>
		<pubDate>Thu, 10 Apr 2008 06:05:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-30</guid>
		<description>[...] http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/ [...]</description>
		<content:encoded><![CDATA[<p>[...] <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> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://blog.alastairdawson.com/2006/07/26/rails-stringio-file-upload/comment-page-1/#comment-29</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Tue, 02 Oct 2007 17:05:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-29</guid>
		<description>Thanks a lot Niels! That&#039;s exactly what I needed. I couldn&#039;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.alastairdawson.com/2006/07/26/rails-stringio-file-upload/comment-page-1/#comment-28</link>
		<dc:creator>Niels</dc:creator>
		<pubDate>Sun, 22 Jul 2007 15:36:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-28</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&#039;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(&quot;your/file/goes/here&quot;, &quot;wb&quot;) { &#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.alastairdawson.com/2006/07/26/rails-stringio-file-upload/comment-page-1/#comment-27</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Wed, 02 May 2007 19:26:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-27</guid>
		<description>Like Bart said, I am having that problem now.  Some files actually come across as StringIO.  I don&#039;t know if it is based on the File Type or the Size of the file, but I can&#039;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.alastairdawson.com/2006/07/26/rails-stringio-file-upload/comment-page-1/#comment-26</link>
		<dc:creator>Bart</dc:creator>
		<pubDate>Thu, 15 Mar 2007 05:51:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-26</guid>
		<description>If you&#039;re file is small, you get a StringIO object.  So only saving if you don&#039;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.alastairdawson.com/2006/07/26/rails-stringio-file-upload/comment-page-1/#comment-25</link>
		<dc:creator>chiamingen</dc:creator>
		<pubDate>Fri, 23 Feb 2007 06:58:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-25</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.alastairdawson.com/2006/07/26/rails-stringio-file-upload/comment-page-1/#comment-24</link>
		<dc:creator>ira S.</dc:creator>
		<pubDate>Mon, 04 Dec 2006 02:22:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-24</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.alastairdawson.com/2006/07/26/rails-stringio-file-upload/comment-page-1/#comment-23</link>
		<dc:creator>Adam T.</dc:creator>
		<pubDate>Mon, 27 Nov 2006 05:29:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.vixiom.com/2006/07/26/rails-stringio-file-upload/#comment-23</guid>
		<description>This post helped me out more than you know.

I&#039;m not sure why file uploading in Rails is such a black-box area filled with weird special cases, but it&#039;s nice to know I wasn&#039;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>
