Displaying 20 results from an estimated 1000 matches similar to: "Rails, lighttpd and the Expires header"
2010 Nov 03
2
send_file but not send_data?
So this is the original code I used, and it worked
send_file ''vendor/sprites/not-found.png'', {:filename =>
"sprite-not-found.png", :type => "image/png", :disposition => "inline"}
Now I switched it to this (going to be adding imageMagick)
send_data File.read(''vendor/sprites/not-found.png''), {:filename =>
2009 Nov 08
2
send_data with jpeg not working
I''m a newbie having trouble using send_data to send a jpeg file to the
browser for display in an html img tag. This is the relevant code
from my controller (photos_controller.rb):
def retrieve
@photo = Photo.find(params[:id])
send_data File.read(@photo.abs_img_path), :type => "image/
jpeg", :disposition => "inline"
end
def download
@photo =
2006 Apr 05
1
send_file VS. send_data (performance)
Does anybody know if there is a big performance/time cost difference
between these two methods of serving a file:
------------------------------- #1
-----------------------------------------
send_file "test.png", :type => ''image/png'', :disposition => ''inline''
-------------------------------
#2------------------------------------------
2006 Aug 08
2
send_file problem
I''m attempting to use send_file to send an image file from
public/images. The file is world readable.
I keep getting the following error:
A ActionController::MissingFile occurred in account#current_logo:
Cannot read file public/images/logo.png
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/streaming.rb:55:in
`send_file''
I''ve tried supplying
2006 Apr 06
1
Rmagick file conversion
I am using rmagick to convert files stored as a tiff to either pdf or
jpg for display to the user. A snippet of test code from the controller
follows. It works OK. ( it does need a sanitizer )
require RMagick
def pdf
@sdoc = Sdoc.find(params[:id])
@fname = ''/var/www/images/'' + @sdoc.fname
@nf = Magick::ImageList.new(@fname)
2006 Oct 25
7
Sending a file *and* rendering a page
Anyone know how to send a file/data to the user agent (download it)
using #send_file or #send_data, *and* render a new page in the same
action?
This just sends the file and doesn''t render the page:
def gimme
...
send_data(our_data, :filename => ''output.csv'', :disposition =>
''attachment'')
end
And this will give a Double-Render error:
2006 Feb 28
1
ArgumentError (string contains null byte) -- file upload problem
Hi,
Controller code:
if params[:main_image]
image = Image.new
image.blob = params[:main_image].read
@product.main_image.destroy if @product.main_image
@product.main_image = image
end
When I try to display the image using send_data, I get the following error:
ArgumentError (string contains null byte):
2010 Apr 22
7
Making ActiveSupport::Cache consistent
Lighthouse ticket: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4452
I have recently been working on some gems that utilize
ActiveSupport::Cache and ran into some issues with the different
implementations handling the same functionality differently. One of
the issues was that I couldn''t rely on expiring entries with
the :expires_in option. MemCacheStore takes this
2006 Feb 16
2
Making the browser cache an action
Hi!
What HTTP headers do I have to sent to make the browser cache the
output of an action?
I tried:
request.delete(''Cache-control'') but no luck.
It''s an action that sends an image to the browser, hence I need that.
Thanks,
Rob
2007 Feb 12
6
Cannot send_file then delete it
My application accepts a form to create multiple large(100''s of MB)
temporary files and then zip''s them up to send off to a user.
I have the files constructed, and the zipping working. The problem is
that if I use send_file to send the zip off to the user, I cannot
delete the file afterwards as it seems send_file forks off another
process and deletes the file before the
2007 Dec 17
2
Error in send_file
I''m trying to add a link to download a zip file. I created a
controller method that makes the call to send_file:
def getzip
send_file ''file.zip''
end
When I navigate to this link I get a MissingFile exception. The file
definitely exists (and U triple-checked paths and spelling) and the
permissions are 644. I tried moving it to the /public folder and
updating the
2005 Feb 13
6
Apache config help needed
Hi all,
I''m (STILL) plugging away trying to get rails to work under Apache2
Rails 0.9.5 Apache 2, OS Mandrake Linux 10.1
Apache is already running other stuff on /pluto/ and /localhost/ so I wish
to install a new virtual host for rails to avoid upsetting anything.
Added rails to my hosts file, and edited conf/Vhosts.conf to contain
NameVirtualHost 192.168.0.254
<VirtualHost
2010 Apr 29
2
send_data => invalid byte sequence in US-ASCII
I''m trying to display a generated .png plot via send_data(), but it
results in a server error "invalid byte sequence in US-ASCII" error.
I''m pretty sure this means that I need to specify the encoding
somewhere, but I haven''t been able to figure out where or how to do so.
Some particulars:
I''m running gnuplot through a pipe to generate a plot in .png
2006 Jul 16
0
send_file with stream enabled
Has anyone managed to use send_file with :stream => true?
I''m currently still developing using Rails 1.1.2 on windows xp so might
be OS problem. But google results show this also happen on linux hosts.
I think using send_file with :stream => false is pointless. Since
send_data does exactly the same thing. Or am I mistaken?
Thanks.
--
Posted via http://www.ruby-forum.com/.
2006 Jan 04
4
How to open a pdf file in new window
Hi all
I made a pdf file in ruby and to display it used the method send_data
like
#
send_data pdf.render, :filename => "Hello.pdf",:type =>
"application/pdf"
#
Now I want to open it in another window or as a popup. How can I achieve
it?
Thanks to all.
Sainaba.
--
Posted via http://www.ruby-forum.com/.
2005 Dec 16
0
caching rails generated images
Hello,
I use Ruby on Rails to generate images, which are delivered via
mod_fastcgi to apache2.
These images should be cached using mod_cache and mod_disk_cache.
But it does not work.
In Rails I set my http headers like this:
expires_in 30.hours, :private => false
@response.headers[''Last-Modified''] = im.serie.received
2007 Feb 23
1
How to make Rails send a file that is being written
I''m trying to build a simple proxy to Amazon S3 that would allow a
client to request a url that gets mapped to a S3 Object by Rails and
streamed back to the client.
For S3 integration, I use the highly recommended gem AWS::S3
(http://amazon.rubyforge.org/), and to send a file, I simply use the
send_file function.
The concept works BUT the I can''t get the file to be sent as
2008 Nov 19
3
Rails.cache and problem with model id?
I have the following:
MODEL:
def self.get_tag_cloud
Rails.cache.fetch(''fetish_tag_cloud'', :expires_in => 1.hour) do
find(:all, :conditions => [ "approved_for_tag_cloud = true"], :order
=> "LTRIM(name)")
end
end
CONTROLLER:
def index
@fetishes = Fetish.get_tag_cloud
end
VIEW:
....
<% @fetishes.each do |fetish| -%>
2007 Jun 07
6
Can't download files with send_data or send_file
I have a form_remote_tag that calls a method to print out a csv file
for download. If I tell the form_remote_tag to update a div the data
comes up in that div, but otherwise I can''t get the browser to
acknowledge the sent file.
>From view:
<%= form_remote_tag :url => {:action => "csv_dump" }%>
<%= submit_tag "Download Complete List" ,:name
2012 Nov 03
1
Volatile cache keys with Rails and Redis
Does Rails automatically set an EXPIRE attribute on keys when working with
Redis, or will an old key sit there forever if it''s never manually cleared
out? This is mostly a concern when using ActiveModel''s "cache_key":
<%= cache @post do %>
The cache-key will be something like views/posts/744-20120613070958 . When
the post is updated, and therefore gets a new