<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>andy goundry</title>
	<atom:link href="http://www.andygoundry.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andygoundry.com</link>
	<description>ruby developer, agile manager, dad</description>
	<lastBuildDate>Wed, 24 Apr 2013 13:09:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Emulating IE 7 and 8</title>
		<link>http://www.andygoundry.com/2013/04/24/emulating-ie-7-and-8/</link>
		<comments>http://www.andygoundry.com/2013/04/24/emulating-ie-7-and-8/#comments</comments>
		<pubDate>Wed, 24 Apr 2013 13:09:57 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=702</guid>
		<description><![CDATA[Add this to your header:
&#60;meta http-equiv=&#8221;X-UA-Compatible&#8221; content=&#8221;IE=EmulateIE7&#8243; /&#62;
]]></description>
			<content:encoded><![CDATA[<p>Add this to your header:</p>
<p>&lt;meta http-equiv=&#8221;X-UA-Compatible&#8221; content=&#8221;IE=EmulateIE7&#8243; /&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2013/04/24/emulating-ie-7-and-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Designing web application systems that ease constraints and increase request throughput</title>
		<link>http://www.andygoundry.com/2012/03/08/why-storing-static-content-in-a-database-is-against-the-goal-of-application-development/</link>
		<comments>http://www.andygoundry.com/2012/03/08/why-storing-static-content-in-a-database-is-against-the-goal-of-application-development/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 12:15:43 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=689</guid>
		<description><![CDATA[In 2012 I never really expected to be having conversations about why storing static file data in a database within a web app is generally a bad idea, but i have. So, as i provided my reasoning, it became clear that i could blog about this too. Comments most welcome.
The goals of software development within [...]]]></description>
			<content:encoded><![CDATA[<p>In 2012 I never really expected to be having conversations about why storing static file data in a database within a web app is generally a bad idea, but i have. So, as i provided my reasoning, it became clear that i could blog about this too. Comments most welcome.</p>
<h2>The goals of software development within a multi-tiered system</h2>
<p>To me, the aims of software development within a multi-tiered system are to constantly simplify the system, plus reduce the overhead on the bottleneck parts within the system. Web apps in particular have so many interdependent parts, that it&#8217;s essential that a developer doesn&#8217;t add to the complexity. On top of this, as web apps generally have 2 bottlenecks (the application server and the database server), which both govern the overall throughput of requests through the entire system (impacting performance and cost &#8211; because we have to scale as these bottlenecks become blocked), it&#8217;s our aim to constantly take load off of these parts, to free them up to focus on the stuff that only they can do. When we do this, we gain immediate performance benefits, plus we bake scalability and stability into the design.</p>
<p>We&#8217;ve all seen this with the use of page and fragment caching. We use these techniques because we understand that serving content from the web-server and file system is super fast, plus easy to make faster.</p>
<h2>Why storing static files in a database is against the goal</h2>
<p>It&#8217;s these inherent rules and our experience that scare us when we hear about moving activity from non-bottleneck parts of the system (the filesystem and web server) to the bottleneck parts. It&#8217;s almost instinctive that we don&#8217;t even need to dig any deeper, because it just makes sense &#8211; if you start overloading the bottleneck parts of the system, you are working against the overall goal of the architecture &#8211; increase throughput without increasing costs. Also, when you take this step away from what&#8217;s normally considered the aim of the design, you end up in new territory. How will you resolve performance issues when they arise (and they will)? You can no longer use the techniques designed to take load off the bottlenecks, because you&#8217;re designed the system to overload the bottlenecks. It&#8217;s anti-performance by design.</p>
<p>So, when considering serving files to end user&#8217;s browsers, certain technologies have become the norm because they offer a risk free, high performance solution, and are known now to be the least constrained parts within the system (on average). Serving files from a file system via Apache or some other web server will always be the fastest and simplest solution, and the attention within the industry to make this faster is ongoing. The industry really cares about making this stuff fast. Also, serving content from the file system puts 0 overhead on the application, meaning that doing so frees up the system and reduces the need to add tin as more users upload and download files from your app. The beauty here is that it no longer really matters how many files have been uploaded to your web app, nor does it even matter much how many people want to concurrently download those files. Why? Because the file system and web server are not system bottlenecks; they really can handle the traffic and both are easy to scale if you need to. Now imagine moving those same files to the database, with each download streamed via the application server (because every byte would need to be streamed through the application). What do you think will happen to the bottlenecks? What will happen to overall performance as more users upload and download files? All of a sudden, you have landed in a really challenging place, where the only really obvious solution is to add tin (be it virtual or physical). Your database would need to be scaled (increasing costs), as would your application server (further increasing costs). Plus, unless you have bottomless pockets, you&#8217;ve effectively baked in a ceiling into your app. At some point, you are going to have to start bouncing requests, because the cost of serving them is going to be too high.</p>
<p>So, are there any situations when storing files in database on a web app make sense? The only one i can find in google is when you&#8217;re uploading images and you need absolute integrity of the metadata. Storing everything in the database is the only way to achieve this, because there can be some discrepancy between file system metadata and the data of the linked file in the database (such as the created time stamp).</p>
<h2>Things to consider if you choose to store static files in postgres</h2>
<p>Other than this case, it just doesn&#8217;t make sense to put strain on the bottleneck parts of the system.</p>
<p>On top of this, when storing file data in a postgres database, you have a few other things to consider:</p>
<ul>
<li>When using bytea columns, you need to be careful about storing &#8220;large&#8221; files.<br />
A &#8220;large&#8221; file means one that exceeds the amount of memory you have in the database. This is caused by the fact that you have to assemble the whole SQL INSERT command with all the file data, which may consume a lot of memory (and the need to escape the BYTEA data makes this even worse). For example in PHP (because that&#8217;s the example i have to hand), there is a memory_limit option, usually set to 8MB (which is quite reasonable size), and you&#8217;ll exceed this limit with a 2MB file (you have to escape the data before using it in INSERT). You may increase the memory_limit value a little, but on shared server the admin won&#8217;t be very happy about that (and I completely understand his reasons).</li>
<li>When using blobs, you need to be careful about blob integrity<br />
You may delete a BLOB that is still referenced from a table. You may create AFTER UPDATE and AFTER DELETE triggers to remove orphaned BLOBs, or use &#8220;lo&#8221; contrib package. Anyway none of these solutions enforces the referential integrity.</li>
</ul>
<h2>Summary</h2>
<p>All in all, I feel that a system designer needs to focus solidly on request throughput within a system. I don&#8217;t believe in early system optimisations, because such optimisations can&#8217;t be considered optimisations at all until you know what your bottlenecks are. Instead, I feel that following a few simple rules are the way to go:</p>
<ul>
<li>Keep the design simple &#8211; if it *feels* wrong and less-than-simple, it probably is.</li>
<li>Use the &#8220;best tool for the job&#8221;. To enable access to uploaded files, file systems and webservers are simply great at serving static content and reduce overhead on your application and database. It just &#8220;makes sense&#8221;.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2012/03/08/why-storing-static-content-in-a-database-is-against-the-goal-of-application-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to solve &#8220;Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension&#8221;</title>
		<link>http://www.andygoundry.com/2012/03/02/how-to-solve-geminstallerextensionbuilderror-error-failed-to-build-gem-native-extension/</link>
		<comments>http://www.andygoundry.com/2012/03/02/how-to-solve-geminstallerextensionbuilderror-error-failed-to-build-gem-native-extension/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 19:33:23 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[bundler]]></category>
		<category><![CDATA[rvm]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=686</guid>
		<description><![CDATA[With the joys of ruby 1.8.7 on OS X 10.7.3, i had to include a manual build step to get get mysql to build. This was the error i was seeing:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient&#8230; no
checking for main() in -lm&#8230; yes
checking for mysql_query() in -lmysqlclient&#8230; no
checking for [...]]]></description>
			<content:encoded><![CDATA[<p>With the joys of ruby 1.8.7 on OS X 10.7.3, i had to include a manual build step to get get mysql to build. This was the error i was seeing:</p>
<blockquote><p>Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.</p>
<p>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb<br />
checking for mysql_query() in -lmysqlclient&#8230; no<br />
checking for main() in -lm&#8230; yes<br />
checking for mysql_query() in -lmysqlclient&#8230; no<br />
checking for main() in -lz&#8230; yes<br />
checking for mysql_query() in -lmysqlclient&#8230; no<br />
checking for main() in -lsocket&#8230; no<br />
checking for mysql_query() in -lmysqlclient&#8230; no<br />
checking for main() in -lnsl&#8230; no<br />
checking for mysql_query() in -lmysqlclient&#8230; no<br />
checking for main() in -lmygcc&#8230; no<br />
checking for mysql_query() in -lmysqlclient&#8230; no<br />
*** extconf.rb failed ***<br />
Could not create Makefile due to some reason, probably lack of<br />
necessary libraries and/or headers.  Check the mkmf.log file for more<br />
details.  You may need configuration options.</p></blockquote>
<p>The solution was to manually install the gem that had been stored in the temporary directory:</p>
<blockquote><p>cd~/.bundler/tmp/85326/gems/mysql-2.8.1/</p>
<p>sudo gem install mysql &#8212; &#8211;with-mysql-config=/usr/local/mysql/bin/mysql_config</p></blockquote>
<p>Once done, bundle install worked and used the installed gem</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2012/03/02/how-to-solve-geminstallerextensionbuilderror-error-failed-to-build-gem-native-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running Ruby 1.8.7 and 1.9.2, RVM 1.10.3, OS X 10.7.3 and Xcode 4.3</title>
		<link>http://www.andygoundry.com/2012/02/24/helping-out-rvm-on-mac/</link>
		<comments>http://www.andygoundry.com/2012/02/24/helping-out-rvm-on-mac/#comments</comments>
		<pubDate>Fri, 24 Feb 2012 21:56:44 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rvm]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=660</guid>
		<description><![CDATA[I recently updated to OS X 10.7.3 and RVM 1.10.3. The OS X update seems to have confused rvm by changing to a different compiler, resulting in &#8216;rvm install&#8217; falling with this error:
The provided compiler &#8216;/usr/bin/gcc&#8217; is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.
The solution that worked [...]]]></description>
			<content:encoded><![CDATA[<p>I recently updated to OS X 10.7.3 and RVM 1.10.3. The OS X update seems to have confused rvm by changing to a different compiler, resulting in &#8216;rvm install&#8217; falling with this error:</p>
<blockquote><p>The provided compiler &#8216;/usr/bin/gcc&#8217; is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.</p></blockquote>
<p>The solution that worked for me to install 1.8.7 was to tell rvm which compiler to use:</p>
<blockquote><p>CC=/usr/bin/gcc-4.2 rvm install 1.8.7</p></blockquote>
<p>This worked as expected.</p>
<p>However, trying to install 1.9.2 or above using the same method failed. So, i tried reinstalling Xcode, to no-avail. I then uninstalled Xcode devtools (sudo /Developer/Library/uninstall-devtools) and installed <a href="https://github.com/kennethreitz/osx-gcc-installer" target="_blank">osx-gcc-installer</a>. After this, i was able to install 1.9.2 using &#8216;CC=/usr/bin/gcc rvm install 1.9.2&#8242;, but it reported errors</p>
<blockquote><p>Ruby &#8216;ruby-1.9.2-p290&#8242; was build using clang &#8211; but it&#8217;s not (fully) supported, expect errors</p></blockquote>
<p>Let&#8217;s see how well this works out. If i get errors, there must be a different compiler i can force rvm to use.</p>
<p>Well, the lack of Xcode devtools resulted in this error when Installing rmagick (2.13.1) with native extensions:</p>
<blockquote><p>checking for stdint.h&#8230; *** extconf.rb failed ***<br />
Could not create Makefile due to some reason, probably lack of<br />
necessary libraries and/or headers.  Check the mkmf.log file for more<br />
details.  You may need configuration options.</p></blockquote>
<p>So, i re-installed devtools and tried again. Let&#8217;s see how well this works.</p>
<p><strong>Update</strong></p>
<p>1.9.2 is working fine, but 1.8.7 is raising this error:</p>
<blockquote><p>~/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault</p></blockquote>
<p>Time to investigate what&#8217;s going on here!</p>
<p>1. rvm uninstall 1.8.7 &amp;&amp; CC=/usr/bin/gcc-4.2 rvm install 1.8.7</p>
<blockquote><p>Same error: ~/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault</p></blockquote>
<p>2. rvm uninstall 1.8.7 &amp;&amp; CC=/usr/bin/gcc-4.2 rvm install ruby-1.8.7 &#8211;force</p>
<blockquote><p>Same error: ~/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault</p></blockquote>
<p>3. rvm install ree</p>
<blockquote><p><strong><span style="color: #339966;">Worked!</span></strong></p></blockquote>
<p><span style="color: #339966;"><strong>So, it seems that this setup requires ree</strong></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2012/02/24/helping-out-rvm-on-mac/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Debugging cucumber scenarios in Rubymine</title>
		<link>http://www.andygoundry.com/2012/02/01/debugging-cucumber-scenarios-in-rubymine/</link>
		<comments>http://www.andygoundry.com/2012/02/01/debugging-cucumber-scenarios-in-rubymine/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 15:52:10 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Rubymine]]></category>
		<category><![CDATA[bdd]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=645</guid>
		<description><![CDATA[Debugging cucumber scenarios in Rubymine is wonderfully simple. Here&#8217;s how i do it:
Create a cucumber step that puts the app into debug mode and pops open the current page that&#8217;s being debugged

I use Rubymine&#8217;s gutter breakpoints, and I add the breakpoint after the save_and_open_page method call, so the page pops open before entering the debugger.
Insert [...]]]></description>
			<content:encoded><![CDATA[<p>Debugging cucumber scenarios in Rubymine is wonderfully simple. Here&#8217;s how i do it:</p>
<h3><span style="font-weight: normal;">Create a cucumber step that puts the app into debug mode and pops open the current page that&#8217;s being debugged</span></h3>
<p><img class="alignnone size-full wp-image-658" title="Screen Shot 2012-02-01 at 16.00.42" src="http://www.andygoundry.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-01-at-16.00.42.png" alt="Screen Shot 2012-02-01 at 16.00.42" width="258" height="62" /></p>
<p>I use Rubymine&#8217;s gutter breakpoints, and I add the breakpoint after the save_and_open_page method call, so the page pops open before entering the debugger.</p>
<h3><span style="font-weight: normal;">Insert the step into whichever scenario i wish to debug</span></h3>
<p><img class="alignnone size-full wp-image-647" title="Screen Shot 2012-02-01 at 15.43.25" src="http://www.andygoundry.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-01-at-15.43.25.png" alt="Screen Shot 2012-02-01 at 15.43.25" width="569" height="71" /></p>
<h3><span style="font-weight: normal;">Run the scenario in debug mode</span></h3>
<p><img class="alignnone size-full wp-image-649" title="Screen Shot 2012-02-01 at 15.48.36" src="http://www.andygoundry.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-01-at-15.48.36.png" alt="Screen Shot 2012-02-01 at 15.48.36" width="355" height="528" /></p>
<h3><span style="font-weight: normal;">Inspect the app&#8217;s objects in Rubymine&#8217;s Watches</span></h3>
<p><img class="alignnone size-full wp-image-648" title="Screen Shot 2012-02-01 at 15.36.27" src="http://www.andygoundry.com/wp-content/uploads/2012/02/Screen-Shot-2012-02-01-at-15.36.27.png" alt="Screen Shot 2012-02-01 at 15.36.27" width="637" height="152" /></p>
<p>Pretty sweet! Super easy and extremely useful.</p>
<p>Rubymine&#8217;s a great app, and i&#8217;m just starting to scratch the surface.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2012/02/01/debugging-cucumber-scenarios-in-rubymine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to deploy a git tag to Heroku</title>
		<link>http://www.andygoundry.com/2012/01/26/how-to-deploy-a-git-tag-to-heroku/</link>
		<comments>http://www.andygoundry.com/2012/01/26/how-to-deploy-a-git-tag-to-heroku/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 22:56:33 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[heroku]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=642</guid>
		<description><![CDATA[Simple:
git push heroku tag_name:master &#8211;force
The &#8211;force is not normally needed, but i needed it because i&#8217;d already deployed git head, so needed this to avoid git complaints
]]></description>
			<content:encoded><![CDATA[<p>Simple:</p>
<blockquote><p>git push heroku tag_name:master &#8211;force</p></blockquote>
<p>The &#8211;force is not normally needed, but i needed it because i&#8217;d already deployed git head, so needed this to avoid git complaints</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2012/01/26/how-to-deploy-a-git-tag-to-heroku/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ensuring postgres gem is installed on heroku when using Rails 3.1</title>
		<link>http://www.andygoundry.com/2012/01/07/ensuring-postgres-gem-is-installed-on-heroku-when-using-rails-3-1/</link>
		<comments>http://www.andygoundry.com/2012/01/07/ensuring-postgres-gem-is-installed-on-heroku-when-using-rails-3-1/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 00:54:43 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[bundler]]></category>
		<category><![CDATA[heroku]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=636</guid>
		<description><![CDATA[It turns out that Rails 3.1 doesn&#8217;t come with a database adapter. So, when deploying to heroku, the app will blow up unless you add the require postgres gem to your gem file:
group :production do
gem &#8220;pg&#8221;
end
group :production do
gem &#8220;pg&#8221;
end
This resolves the heroku error
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection&#8217;: Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is [...]]]></description>
			<content:encoded><![CDATA[<p>It turns out that Rails 3.1 doesn&#8217;t come with a database adapter. So, when deploying to heroku, the app will blow up unless you add the require postgres gem to your gem file:</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">group :production do</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">gem &#8220;pg&#8221;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">end</div>
<blockquote><p>group :production do</p>
<p>gem &#8220;pg&#8221;</p>
<p>end</p></blockquote>
<p>This resolves the heroku error</p>
<blockquote><p>/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection&#8217;: Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2012/01/07/ensuring-postgres-gem-is-installed-on-heroku-when-using-rails-3-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ensuring that Heroku does not install gems within the Bundler :development group</title>
		<link>http://www.andygoundry.com/2012/01/07/ensuring-that-heroku-does-not-install-gems-within-the-bundler-development-group/</link>
		<comments>http://www.andygoundry.com/2012/01/07/ensuring-that-heroku-does-not-install-gems-within-the-bundler-development-group/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 00:38:06 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[bundler]]></category>
		<category><![CDATA[heroku]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=634</guid>
		<description><![CDATA[Tonight, i ran into an issue with Heroku, where is was failing when installing a gem that i have within my :development bundler group:
group :development, :test, :cucumber do
gem &#8216;ruby-debug19&#8242;
end
As the clear solution was to prevent heroku installing gems that it didn&#8217;t need, i found this handy heroku command:
heroku config:add BUNDLE_WITHOUT=&#8221;development:test:cucumber&#8221;
Running this has told heroku to [...]]]></description>
			<content:encoded><![CDATA[<p>Tonight, i ran into an issue with Heroku, where is was failing when installing a gem that i have within my :development bundler group:</p>
<blockquote><p>group :development, :test, :cucumber do</p>
<p>gem &#8216;ruby-debug19&#8242;</p>
<p>end</p></blockquote>
<p>As the clear solution was to prevent heroku installing gems that it didn&#8217;t need, i found this handy heroku command:</p>
<blockquote><p>heroku config:add BUNDLE_WITHOUT=&#8221;development:test:cucumber&#8221;</p></blockquote>
<p>Running this has told heroku to ignore gems that it doesn&#8217;t need, meaning the deploy worked fine. Further details: http://devcenter.heroku.com/articles/bundler</p>
<p>This resolves the heroku error:</p>
<blockquote><p>Installing linecache19 (0.5.12) with native extensions /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions&#8217;: ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2012/01/07/ensuring-that-heroku-does-not-install-gems-within-the-bundler-development-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Paperclip generated expiring S3 urls with RSpec, Cucumber and Timecop</title>
		<link>http://www.andygoundry.com/2011/12/21/using-cucumber-to-test-s3-expiring-urls/</link>
		<comments>http://www.andygoundry.com/2011/12/21/using-cucumber-to-test-s3-expiring-urls/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 07:07:15 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rspec]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=529</guid>
		<description><![CDATA[The need
I have a Rails app that is using Paperclip to generate expiring urls for files stored in S3. The urls are set to expire after 1 minute. As much as i trust Paperclip and Amazon, I need tests that prove that these generated urls do in fact expire on time, and that visitors to [...]]]></description>
			<content:encoded><![CDATA[<h2>The need</h2>
<p>I have a Rails app that is using Paperclip to generate expiring urls for files stored in S3. The urls are set to expire after 1 minute. As much as i trust Paperclip and Amazon, I need tests that prove that these generated urls do in fact expire on time, and that visitors to those files after they&#8217;ve expired are prevented from accessing the file.</p>
<h2 style="font-size: 1.5em;">Disclaimer</h2>
<p>This has been a bit of a rush, so no doubt i&#8217;ll refactor and tidy the code and this post laster today / in the week.</p>
<h2 style="font-size: 1.5em;">The solution</h2>
<p>I&#8217;ve used RSpec and Cucumber to check expiring urls that the system generates to ensure they expire successfully. RSpec simply checks that a generated url includes the Expires parameter and it&#8217;s value is set exactly to 60 seconds from now. Cucumber goes further than this by uploading files and checking if they are accessible before and after expiration.</p>
<h3><span style="color: #333399;"> RSpec to simply test that the expiration time generated for a link is correctly set to 1 minute<br />
</span></h3>
<p>This test simply asks the model containing the attachment (in this case an &#8220;Asset&#8221; model), how many seconds from now remain before the attachment expires.</p>
<p><strong>Spec</strong></p>
<blockquote><p>describe Asset do</p>
<p style="padding-left: 30px; "><strong> it &#8220;should return an attachment link that expires within 1 minute&#8221; do</strong></p>
<p style="padding-left: 60px;">asset = Factory.build(:asset)<br />
asset.seconds_until_attachment_expires.should == 60</p>
<p style="padding-left: 30px; ">end</p>
<p>end</p></blockquote>
<p>This depends on a few new methods in the Asset model class, which take care of extracting the Expires param from the expiring url, and comparing to Time.now.</p>
<p><strong>Asset Model Class</strong></p>
<p>First, we create an instance helper method that returns the number of seconds an object&#8217;s url has left before it expires</p>
<blockquote><p>def seconds_until_attachment_expires</p>
<p style="padding-left: 30px;">Asset.seconds_until_attachment_expires(expiring_attachment_url)</p>
<p>end</p></blockquote>
<p>I decided to pass the responsibility of calculating this number to a class method. I did this because the Cucumber tests need to request the same calculation for urls that were generated in the past. If they interacted with an instance of the Asset class, by default it would return a new url each time it was asked. So, rather than clutter up the instance method with a decision about whether to issue a new url or return an existing one, i simply passed the responsibility to the class. That seems to work for now, although I might refactor it later.</p>
<p>Next, we create the class level method that calculates time left until expiration. This accepts a url, meaning we can test urls generated now or in the past</p>
<blockquote><p>def self.seconds_until_attachment_expires(url)</p>
<p style="padding-left: 30px;">seconds = attachment_expiration_in_seconds_from_epoch(url) &#8211; Time.now.strftime(&#8221;%s&#8221;).to_i<br />
seconds.round</p>
<p>end</p></blockquote>
<p>This method simply strips the time from the generated url (via the attachment_expiration_in_seconds_from_epoch method) and rounds the value.</p>
<blockquote><p>def self.attachment_expiration_in_seconds_from_epoch(url)</p>
<p style="padding-left: 30px;">url.split(&#8221;&amp;&#8221;).second.split(&#8221;=&#8221;).last.to_i</p>
<p>end</p></blockquote>
<p>Clearly, this is tightly coupled to the format of the generated url string, so a cleaner way should be sought. However, for now, this method is only used in the tests and it does work, so it&#8217;ll do for the moment.</p>
<p>Finally, to ensure that Rspec, Cucumber and the app all interact with a url generated exactly 60 seconds from now, we create a model instance method that generates the link. All requests for the link call this method.</p>
<blockquote><p>def expiring_attachment_url</p>
<p style="padding-left: 30px;">attachment.expiring_url(60)</p>
<p>end</p></blockquote>
<h3 style="font-size: 1.17em;"><span style="color: #333399;">Cucumber to test actual file access via the browser</span></h3>
<p>Cucumber takes things 1 step further. It interacts with all the same methods that we created on the Asset model, but also goes off and uploads attachments and then tries to access them before and after they&#8217;ve expired. We use <a href="http://www.google.co.uk/url?sa=t&amp;rct=j&amp;q=timecop%20gem&amp;source=web&amp;cd=1&amp;ved=0CCEQFjAA&amp;url=https%3A%2F%2Fgithub.com%2Fjtrupiano%2Ftimecop&amp;ei=CarxTpfiJMLLswbLlM3mDw&amp;usg=AFQjCNHx9MgEnBzIw0ysdxhOMlxC40j_4Q">Timecop</a> to create expired urls, and a Cucumber <em>before</em> hook to ensure all scenarios run from the current time by default.</p>
<p><strong>Scenarios</strong></p>
<blockquote><p>@selenium<br />
<strong>Scenario: Viewing an active attachment on an object</strong></p>
<p style="padding-left: 30px;"><strong> </strong>Given some object has been created and a plain text file attached<br />
When I visit the object&#8217;s attachment url<br />
Then I should see the contents of the uploaded attachment<br />
And I should not see &#8220;Request has expired&#8221;</p>
<p>@selenium<br />
<strong>Scenario: Viewing an expired attachment on an object</strong></p>
<p style="padding-left: 30px;"><strong> </strong>Given some object has been created and a plain text file attached<br />
When I visit the object&#8217;s attachment url after it has expired<br />
Then I should not see the contents of the uploaded attachment<br />
And I should see &#8220;Request has expired&#8221;</p>
</blockquote>
<p><strong>features/support/hooks.rb</strong></p>
<blockquote><p>Before do</p>
<p style="padding-left: 30px;">Timecop.return</p>
<p>end</p></blockquote>
<p>NB: For the sake of completeness (even though we&#8217;re not calling Timecop from our Rspec specs), to be completely satisfied that Timecop isn&#8217;t affecting our specs in any unexpected way, we add the same to spec_helper.rb too:</p>
<p><strong>spec/spec_helper.rb</strong></p>
<p><strong><span style="font-weight: normal; "> </span></strong></p>
<blockquote><p>config.before do</p>
<p style="padding-left: 30px;">Timecop.return</p>
<p>end</p></blockquote>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 776px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">config.before do</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 776px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Timecop.return</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 776px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">end</div>
<p><strong>steps</strong></p>
<p>This is where Timecop offers a wonderfully simple way of generating expired urls.</p>
<blockquote><p><strong>And /^I visit the question&#8217;s attachment url after it has expired$/ do</strong></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;"><span style="color: #008080;"><span style="color: #99ccff;"><span style="color: #ff9900;"><span style="color: #333399;"><strong>#First, go back in time 2 minutes and generate the expiring url, and make sure it&#8217;s set to expire in 1 minute</strong><br />
</span> </span> </span> </span> </span> Timecop.freeze(Time.now &#8211; 2.to_i.minutes) do</p>
<p style="padding-left: 60px;">@url = current_object.asset.expiring_attachment_url<br />
Asset.attachment_expires_in(@url).should == 60</p>
<p style="padding-left: 30px;">end</p>
<p style="padding-left: 30px;"><strong><span style="color: #3366ff;"><span style="color: #008080;"><span style="color: #99ccff;"><span style="color: #ff9900;"><span style="color: #333399;"> #Next, return to the current time and make sure the previously generated expiring url has now been expired for 1 minute<br />
</span> </span> </span> </span> </span></strong> Timecop.return<br />
Asset.attachment_expires_in(@url).should == -60</p>
<p style="padding-left: 30px;"><strong><span style="color: #3366ff;"><span style="color: #008080;"><span style="color: #99ccff;"><span style="color: #ff9900;"><span style="color: #333399;"> #Finally, go visit the expired url<br />
</span> </span> </span> </span> </span></strong> visit @url</p>
<p>end</p></blockquote>
<p>When run, cucumber correctly reports that expired urls result in the user seeing the message &#8220;Request has expired&#8221;, and non-expired urls correctly provide access to the uploaded file.</p>
<h2 style="font-size: 1.5em;">Summary</h2>
<p>Although a rough and ready solution, and most likely needing refactoring, it does provide us with a way to test expiration of uploads to S3.</p>
<p>I hope you found this useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2011/12/21/using-cucumber-to-test-s3-expiring-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making S3 file uploads private yet accessible via your rails app using Paperclip</title>
		<link>http://www.andygoundry.com/2011/12/20/making-s3-file-uploads-private-yet-accessible-in-rails-with-paperclip/</link>
		<comments>http://www.andygoundry.com/2011/12/20/making-s3-file-uploads-private-yet-accessible-in-rails-with-paperclip/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 17:33:49 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.andygoundry.com/?p=521</guid>
		<description><![CDATA[The need
I needed to make file uploads to S3 secure. Files must be private in S3 (i.e. not accessible if someone guessed the url), yet accessible via the rails based web app.
The solution
Add this to the rails model:
has_attached_file :attachment,
:storage =&#62; :s3,
:s3_credentials =&#62; &#8216;config/amazon_s3.yml&#8217;,
:s3_permissions =&#62; :private
Replaced this in the view:
Replaced: asset.attachment.url
With: asset.attachment.expiring_url(60)
This keeps the files private, and the [...]]]></description>
			<content:encoded><![CDATA[<h2><strong>The need</strong></h2>
<p>I needed to make file uploads to S3 secure. Files must be private in S3 (i.e. not accessible if someone guessed the url), yet accessible via the rails based web app.</p>
<h2><strong>The solution</strong></h2>
<p>Add this to the rails model:</p>
<blockquote><p>has_attached_file :attachment,</p>
<p>:storage =&gt; :s3,</p>
<p>:s3_credentials =&gt; &#8216;config/amazon_s3.yml&#8217;,</p>
<p><strong>:s3_permissions =&gt; :private</strong></p></blockquote>
<p>Replaced this in the view:</p>
<blockquote><p>Replaced: asset.attachment.url</p>
<p>With: asset.attachment.<strong>expiring_url(60)</strong></p></blockquote>
<p>This keeps the files private, and the app creates expiring urls as users request them, which expire after a minute.</p>
<h2>What Amazon Say</h2>
<p><span style="font-family: verdana, arial, sans-serif; line-height: normal;"> </span></p>
<div class="titlepage" style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; padding: 0px; margin: 0px;">
<div style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; padding: 0px; margin: 0px;">
<div style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; padding: 0px; margin: 0px;">
<h2 id="RESTAuthenticationQueryStringAuth" class="title" style="color: #cc6600; font-size: 14px; font-weight: bold; clear: both;">Query String Request Authentication Alternative</h2>
</div>
</div>
</div>
<p style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; margin-bottom: 1em;">You can authenticate certain types of requests by passing the required information as query-string parameters instead of using the <code class="code" style="font-family: 'Courier New', Courier, mono; font-size: 12px;">Authorization</code> HTTP header. This is useful for enabling direct third-party browser access to your private Amazon S3 data, without proxying the request. The idea is to construct a &#8220;pre-signed&#8221; request and encode it as a URL that an end-user&#8217;s browser can retrieve. Additionally, you can limit a pre-signed request by specifying an expiration time.</p>
<div class="section" style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; padding: 0px; margin: 0px;" lang="en">
<div class="titlepage" style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; padding: 0px; margin: 0px;">
<div style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; padding: 0px; margin: 0px;">
<div style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; padding: 0px; margin: 0px;">
<h3 id="CreatingASignature" class="title" style="color: #006699; font-size: 12px; font-weight: bold; padding: 0px;">Creating a Signature</h3>
</div>
</div>
</div>
<p><a name="d0e4215"></a></p>
<p style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; margin-bottom: 1em;">Following is an example query string authenticated Amazon S3 REST request.</p>
<pre class="programlisting" style="font-family: 'Courier New', Courier, mono; font-size: 12px; color: #000066; background-color: #eeeeee; margin-top: 5px; margin-bottom: 5px; overflow-x: auto; overflow-y: auto; width: 1083px; padding: 1em; border: 1px dashed #333333;">GET /photos/puppy.jpg
?AWSAccessKeyId=0PN5J17HBGZHT7JJ3X82&amp;Expires=1141889120&amp;Signature=vjbyPxybdZaNmGa%2ByT272YEAiv4%3D HTTP/1.1
Host: johnsmith.s3.amazonaws.com
Date: Mon, 26 Mar 2007 19:37:58 +0000</pre>
<p style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; margin-bottom: 1em;">The query string request authentication method doesn&#8217;t require any special HTTP headers. Instead, the required authentication elements are specified as query string parameters:</p>
</div>
<table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border: 1px solid #cccccc;" border="0" cellspacing="0">
<colgroup>
<col></col>
<col></col>
<col></col>
</colgroup>
<thead>
<tr>
<th style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #333333; vertical-align: top; background-color: #eeeeee; font-weight: bold; text-align: left; padding: 5px; margin: 0px; border: 1px solid #cccccc;">Query String Parameter Name</th>
<th style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #333333; vertical-align: top; background-color: #eeeeee; font-weight: bold; text-align: left; padding: 5px; margin: 0px; border: 1px solid #cccccc;">Example Value</th>
<th style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #333333; vertical-align: top; background-color: #eeeeee; font-weight: bold; text-align: left; padding: 5px; margin: 0px; border: 1px solid #cccccc;">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; vertical-align: top; padding: 5px; margin: 0px; border: 1px solid #cccccc;"><em><code style="font-family: 'Courier New', Courier, mono; font-size: 12px;">AWSAccessKeyId</code></em></td>
<td style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; vertical-align: top; padding: 5px; margin: 0px; border: 1px solid #cccccc;"><code class="code" style="font-family: 'Courier New', Courier, mono; font-size: 12px;">0PN5J17HBGZHT7JJ3X82</code></td>
<td style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; vertical-align: top; padding: 5px; margin: 0px; border: 1px solid #cccccc;">Your AWS Access Key Id. Specifies the AWS Secret Access Key used to sign the request, and (indirectly) the identity of the developer making the request.</td>
</tr>
<tr>
<td style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; vertical-align: top; padding: 5px; margin: 0px; border: 1px solid #cccccc;"><em><code style="font-family: 'Courier New', Courier, mono; font-size: 12px;">Expires</code></em></td>
<td style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; vertical-align: top; padding: 5px; margin: 0px; border: 1px solid #cccccc;"><code class="code" style="font-family: 'Courier New', Courier, mono; font-size: 12px;">1141889120</code></td>
<td style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; vertical-align: top; padding: 5px; margin: 0px; border: 1px solid #cccccc;">The time when the signature expires, specified as the number of seconds since the epoch (00:00:00 UTC on January 1, 1970). A request received after this time (according to the server), will be rejected.</td>
</tr>
<tr>
<td style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; vertical-align: top; padding: 5px; margin: 0px; border: 1px solid #cccccc;"><em><code style="font-family: 'Courier New', Courier, mono; font-size: 12px;">Signature</code></em></td>
<td style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; vertical-align: top; padding: 5px; margin: 0px; border: 1px solid #cccccc;"><code class="code" style="font-family: 'Courier New', Courier, mono; font-size: 12px;">vjbyPxybdZaNmGa%2ByT272YEAiv4%3D</code></td>
<td style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; vertical-align: top; padding: 5px; margin: 0px; border: 1px solid #cccccc;">The URL encoding of the Base64 encoding of the HMAC-SHA1 of StringToSign.</td>
</tr>
</tbody>
</table>
<p><span style="font-family: verdana, arial, sans-serif; line-height: normal;"> </span></p>
<div class="section" style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; padding: 0px; margin: 0px;" lang="en">
<p style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; margin-bottom: 1em;">The query string request authentication method differs slightly from the ordinary method but only in the format of the <em><code style="font-family: 'Courier New', Courier, mono; font-size: 12px;">Signature</code></em> request parameter and the <em><code style="font-family: 'Courier New', Courier, mono; font-size: 12px;">StringToSign</code></em> element. Following is pseudo-grammar that illustrates the query string request authentication method.</p>
<pre class="programlisting" style="font-family: 'Courier New', Courier, mono; font-size: 12px; color: #000066; background-color: #eeeeee; margin-top: 5px; margin-bottom: 5px; overflow-x: auto; overflow-y: auto; width: 1083px; padding: 1em; border: 1px dashed #333333;">Signature = URL-Encode( Base64( HMAC-SHA1( YourSecretAccessKeyID, UTF-8-Encoding-Of( StringToSign ) ) ) );

StringToSign = HTTP-VERB + "\n" +
    Content-MD5 + "\n" +
    Content-Type + "\n" +
    Expires + "\n" +
    CanonicalizedAmzHeaders +
    CanonicalizedResource;</pre>
<p style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; margin-bottom: 1em;"><em><code style="font-family: 'Courier New', Courier, mono; font-size: 12px;">YourSecretAccessKeyID</code></em> is the AWS Secret Access Key ID Amazon assigns to you when you sign up to be an Amazon Web Service developer. Notice how the <em><code style="font-family: 'Courier New', Courier, mono; font-size: 12px;">Signature</code></em> is URL-Encoded to make it suitable for placement in the query-string. Also note that in <em><code style="font-family: 'Courier New', Courier, mono; font-size: 12px;">StringToSign</code></em>, the HTTP <code class="code" style="font-family: 'Courier New', Courier, mono; font-size: 12px;">Date</code> positional element has been replaced with <em><code style="font-family: 'Courier New', Courier, mono; font-size: 12px;">Expires</code></em>. The <em><code style="font-family: 'Courier New', Courier, mono; font-size: 12px;">CanonicalizedAmzHeaders</code></em> and<em><code style="font-family: 'Courier New', Courier, mono; font-size: 12px;">CanonicalizedResource</code></em> are the same.</p>
<div class="example" style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; padding: 0px; margin: 0px;"><a name="d0e4298"></a></p>
<p class="title" style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; margin-bottom: 1em;"><strong>Example Query String Request Authentication</strong></p>
</div>
</div>
<table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border: 1px solid #cccccc;" border="0" cellspacing="0">
<colgroup>
<col></col>
<col></col>
</colgroup>
<thead>
<tr>
<th style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #333333; vertical-align: top; background-color: #eeeeee; font-weight: bold; text-align: left; padding: 5px; margin: 0px; border: 1px solid #cccccc;">Request</th>
<th style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #333333; vertical-align: top; background-color: #eeeeee; font-weight: bold; text-align: left; padding: 5px; margin: 0px; border: 1px solid #cccccc;">StringToSign</th>
</tr>
</thead>
<tbody>
<tr>
<td style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; vertical-align: top; padding: 5px; margin: 0px; border: 1px solid #cccccc;">
<pre class="programlisting" style="font-family: 'Courier New', Courier, mono; font-size: 12px; color: #000066; background-color: #eeeeee; margin-top: 5px; margin-bottom: 5px; overflow-x: auto; overflow-y: auto; width: 410px; padding: 1em; border: 1px dashed #333333;">GET /photos/puppy.jpg?AWSAccessKeyId=0PN5J17HBGZHT7JJ3X82&amp;
    Signature=rucSbH0yNEcP9oM2XNlouVI3BH4%3D&amp;
    Expires=1175139620 HTTP/1.1

Host: johnsmith.s3.amazonaws.com</pre>
</td>
<td style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; vertical-align: top; padding: 5px; margin: 0px; border: 1px solid #cccccc;">
<pre class="programlisting" style="font-family: 'Courier New', Courier, mono; font-size: 12px; color: #000066; background-color: #eeeeee; margin-top: 5px; margin-bottom: 5px; overflow-x: auto; overflow-y: auto; width: 204px; padding: 1em; border: 1px dashed #333333;">GET\n
\n
\n
1175139620\n

/johnsmith/photos/puppy.jpg</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: verdana, arial, sans-serif; line-height: normal;"> </span></p>
<div class="section" style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; padding: 0px; margin: 0px;" lang="en">
<div class="example" style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; padding: 0px; margin: 0px;">
<div class="example-contents" style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; padding: 0px; margin: 0px;">
<p style="font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; margin-bottom: 1em;">We assume that when a browser makes the GET request, it won&#8217;t provide a Content-MD5 or a Content-Type header, nor will it set any x-amz- headers, so those parts of the <em><code style="font-family: 'Courier New', Courier, mono; font-size: 12px;">StringToSign</code></em></p>
</div>
</div>
</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 25px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">has_attached_file :attachment,</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 25px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">:storage =&gt; :s3,</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 25px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">:s3_credentials =&gt; &#8216;config/amazon_s3.yml&#8217;,</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 25px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">:s3_permissions =&gt; :private</div>
]]></content:encoded>
			<wfw:commentRss>http://www.andygoundry.com/2011/12/20/making-s3-file-uploads-private-yet-accessible-in-rails-with-paperclip/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
