Store templates in Amazon S3

86 views
Skip to first unread message

Emili Parreño

unread,
Dec 26, 2009, 5:49:38 AM12/26/09
to Liquid Templates
Hi! I'm working in an app hosted in Heroku. As you know, Heroku is
cloud computing and your filesystem is only readable. My users should
be able to upload your own themes. When a user upload a zip file with
your theme I put all theme's files on amazon s3. The problem is when I
try to load the theme, I have always the same error

Liquid error: No such template 'topmenu'

I'm not be able to recover the partials from S3. I think the problem
could be here

Liquid::Template.file_system = ::Liquid::LocalFileSystem.new(path)

but I'm not sure

Any of you have experience storing templates on S3

Thanks!

Tobias Lütke

unread,
Dec 29, 2009, 12:30:59 AM12/29/09
to liquid-t...@googlegroups.com
Simply look at the source of the LocalFileSystem partial
implementation and replace it with your own. That's kind of the point
behind an assignable filesystem.

Also, you want to store your templates in the DB not in S3. S3 is kind
of crazy for this as it means every hit to your webapp will generate
about 2+ HTTP hits to s3 which is both expensive and unnecessary.

Just write a some rubyzip code that moves the templates from a zip
file into the DB. that's what Shopify does.

Regards
-- tobi

> --
>
> You received this message because you are subscribed to the Google Groups "Liquid Templates" group.
> To post to this group, send email to liquid-t...@googlegroups.com.
> To unsubscribe from this group, send email to liquid-templat...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liquid-templates?hl=en.
>
>
>

Emili Parreño

unread,
Dec 29, 2009, 5:01:21 AM12/29/09
to liquid-t...@googlegroups.com
Simply look at the source of the LocalFileSystem partial
implementation and replace it with your own. That's kind of the point
behind an assignable filesystem.

Yes, I replaced LocalFileSystem#read_template_file with my own method and now it works fine.
 

Also, you want to store your templates in the DB not in S3. S3 is kind
of crazy for this as it means every hit to your webapp will generate
about 2+ HTTP hits to s3 which is both expensive and unnecessary.

Just write a some rubyzip code that moves the templates from a zip
file into the DB. that's what Shopify does.

Thanks for this tip! obviously store templates in S3 isn't the best idea. I found this plugin [1] to store templates in the DB and I will take a look for it.


Thanks again!



--
Emili Parreño - www.eparreno.com
Ruby/Rails Trainer & Consultant - www.prorubyteam.com
Reply all
Reply to author
Forward
0 new messages