Displaying 20 results from an estimated 2000 matches similar to: "quick send_data question..."
2006 Feb 05
0
validating presence of file uploads
not sure whats going on here, but I''m using some pretty standard code to
manage file uploads in to a db, but having trouble detecting if the file
upload field has been filled or not.
in my Asset Model, I have:
def asset=(asset_field)
self.name = base_part_of(asset_field.original_filename)
self.content_type = asset_field.content_type.chomp
self.data = asset_field.read
end
def
2006 Jul 03
0
Multiple File Upload
Hello together,
I developed a file upload in my application like this (files uploaded
belong to a project):
project_controller.rb:
----------------------
def upload_attachment
project = Project.find(@params[:id])
begin
project.attachments.create(params[:attachment])
rescue
flash[:attachment_error] = "Error at Upload"
end
redirect_to :action => "edit_project", :id
2006 Jul 04
0
Uploading files - getting size
Hi,
I want to get the size of an uploaded file that is saved in the
database. Can you help me?
In the edit view formular there is:
<input id="attachment_title" name="attachment[title]" size="30"
type="text" /> <input id="attachment_attachment"
name="attachment[attachment]" size="30" type="file" />
2006 Mar 06
1
Uploaded File to Database
Hi,
I currently write a tool for my school. Therefore I have to save
uploaded files.
I bought Agile Web Dev. with Rails to learn webdev with Rails.
I''m very new at rails and couln''d find anything on the internet.
Now when I want to save the file data to the mysql database, rails gives
me an error.
My code is the same as written in the book on page 363.
Here is my code of the
2007 Jul 05
2
undefined method `original_filename' for "random.jpg":String
I have a problem getting attachments to work in a specific case...
I have the following data model (this is a relevant subset of it):
- a log can have many journals
- a journal belongs to a log and can have many attachments
- an attachment belongs to a journal
When adding on a new journal to an existing log the new journal form and
the corresponding controller handle the attachment as well and
2008 Jun 15
11
Ouch! Can't figure out this file upload issue...
Okay, so this is driving me crazy. I''m trying to do a file upload
using code from a book.
What happens:
I get wrong number of arguments (1 for 0) in the upload controller
save action. No idea why.
Schema:
The schema for the picture model object is just a textfield named
comments and a binary field called data.
Upload controller:
def get
@picture =Picture.new
end
def save
2006 Feb 06
2
File_field and Firefox
Hi!
Im developing a simple prototype of an application. It fills an oracle
db with data about a file in the filesystem, and save the entire file
in a blob along with some metadata. To get the file in the db i use a
file_field form helper. All goes well with the radrails-integrated
browser, but it doesnt work anymore in firefox. The problem is,
firefox seems to cut the pathname from the file.
Here
2010 Feb 24
6
Yet another send_data :image question...
Guys & gals,
I''m also learning RoR (using v2.3.4). I''ve got a basic scaffold
working for image file creation, and - to a point - image file
display.
The send_data function is working in my controller - no problem. The
model code is able to parse the uploaded file construct too.
def show
@image = Image.find(params[:id])
send_data(@image.binary_data, :type =>
2008 Oct 08
11
Using image_tag and send_data
I am using image_tag to load an image that I''ve saved to the database
(using attachment_fu if you''re curious but that''s probably not
relevant here):
VIEW
<%= image_tag ''/photo/get_image/5'' %>
CONTROLLER
def get_image
@photo=Photo.find(params[:id])
send_data(DbFile.find(@photo.db_file_id).data,
:type =>
2006 May 29
3
File.size() on Uploaded Images Fail
I am checking the file size of an uploaded file and storing it in a filesize
column. It will work just fine when the user uploads any files other than
images (jpg,png,gif).
Word, Excel, Powerpoint, .zip and more all work fine.
This is my model asset.rb that handles the file upload.
def newfile=(newfile_field)
self.filename = base_part_of(newfile_field.original_filename)
self.filetype
2005 Sep 07
0
model constructor errors.
I have a model; I do photo = Photo.new(parameters) parameters
contains: {"picture"=>#<File:C:/DOCUME~1/BART~1/LOCALS~1/Temp/CGI3180.1>}
so i expect that the def picture=(filename) method is called in this
constructor.. this is not the case. Does anyone know why?
params[:photo].each_pair do |id, parameters|
photo = Photo.new(parameters)
end
class Photo
2006 Nov 04
0
send_data from disk
Hi, I''m trying to use send_data to stream a file that is stored on my disk
(not as a blob in the database.)
So, this is what I''ve tried:
send_data File.new(filename).read
But, the file doesn''t download. I think send_data expects something other
than a String (which is returned by File.read.) Anyone know how to get this
working?
The reason this is being done is to
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 =
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 May 22
2
Problem with send_data and csv file produced
hi, i did a search and couldn''t find wat''s the problem with my code...
it seems everything is the same and the result is what i expected but i
am not sure where went wrong....
using send_data function to send the csv file to the client, the file
sending is successfully but when i opened the csv file, something is
wrong...
every statement got a "......" inverted
2006 May 17
0
send_data not working properly with link_remote_to
I''m reading an image in an link_to_remote call,and then using send_data
i send the read image as :type => "image/png" :disposition =>
"inline"...but when the div tag gets updated i see only ascii characters
.....but if i do the same operation using normal call(link_to) i see it
functioning normal ....could someone explain .
my view:
<%=
2012 Mar 13
1
send_data always sends xml file?
I''m trying to use send_data to send a simple text file.
Every reference I can find says I can supply a MIME type with the
":type" option and that will determine the kind of file I get on the
machine that downloads the file I''m sending. Instead I ALWAYS get an
XML file.
here''s the code snippet:
File.open(@temp_download_file_path, ''r'') do
2010 Dec 22
0
image_tag and send_data
i''m storing images in database.
i have this action in controller:
def image
begin
item = StoredItem.find(:first, :conditions => {:id =>
params[:id]})
rescue
return
end
return if item.nil?
if item.image_binary.nil?
render :nothing => true
else
send_data(item.image_binary, :type => item.image_datatype,
:disposition =>
2007 Jul 24
0
send_data and ie
Has anyone else had trouble using send_data with internet explorer. As
usual things were working fine in firefox and safari until I tested in
IE :).
With the following code I''m seeing an image show up in firefox but the
"X" indicating no image found in IE. Any ideas?
@image_data = Image.find(:all, :conditions=>{:url =>
"http://reddit.com"})
@image =
2006 Jun 19
3
can''t dump anonymous class Class
I''m trying to create a document upload system, where most of the code is
the super class Document and just the path to file on the system is
controlled by the sub classes. When I attempt to use my code, I get the
following when I try to save the document.
can''t dump anonymous class Class
Any ideas?
** Migration **
class CreateDocuments < ActiveRecord::Migration
def