search for: original_filename

Displaying 20 results from an estimated 97 matches for "original_filename".

2012 Nov 12
1
undefined method `original_filename' for nil:NilClass
...<%end%>* * <input name=''commit'' type=''submit'' method=''post'' value=''Import''/>* *<%end%>* My controller: *collection_action :status_race, :method => :post do* * * * uploaded_io = params[:uploaded_data].original_filename* * * * File.open(Rails.root.join(''app/importers'', ''uploads'', uploaded_io.original_filename), ''w'') do |file|* * file.write(uploaded_io.read)* * end* * * * RoutesQuickcom.new.run(uploaded_io.original_filename)* * render "sta...
2003 Apr 24
1
R 1.7.0 (Windows) Crashes After using "Install Package from Cran option" within
...N="5.1.2600.1106" PRODUCT_VERSION="5.1.2600.1106" FILE_DESCRIPTION="Advanced Windows 32 Base API" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft? Windows? Operating System" FILE_VERSION="5.1.2600.1106 (xpsp1.020828-1920)" ORIGINAL_FILENAME="advapi32.dll" INTERNAL_NAME="advapi32.dll" LEGAL_COPYRIGHT="? Microsoft Corporation. All rights reserved." VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSU...
2010 Oct 25
0
Rails 3 -NoMethodError (undefined method `original_filename
Hello! I''m using Rails 3, Uploadify, to send images to S3. Right now all the images being uploaded to S3 have the MIME: application/octet-stream I''d like to fix that but I''m getting the following error: NoMethodError (undefined method `original_filename'' for #<ActiveSupport::HashWithIndifferentAccess:0x107c81998>): app/models/photo.rb:29:in `upload_file='' app/controllers/photos_controller.rb:15:in `upload'' app/middleware/flash_session_cookie_middleware.rb:14:in `call'' I think this is be...
2013 Sep 18
2
Accessing model attributes in ActiveSupport::Concern module
...end rescue return true #an error occured but when the image does not exist we still return true end end return true end def replace_image(new_image) File.open(Rails.root.join("public", "images", image_dir, new_image.original_filename), "wb") do |f| if f.write new_image.read delete_image pic_link = new_image.original_filename return true #everything went fine else return false #return false if new image could not be written end end endend The er...
2007 Jun 07
1
problem with multiple file attachment
...uot;, "file") %></td> </tr> <tr> <td bgcolor="#F6F6F6"><%= file_field("test", "file") %></td> </tr> <tr> in controller: if request.post? @picture=params[:picture][:file] @filename = @picture.original_filename @test=params[:test][:file] render_text @filename1 = @picture1.original_filename end my Error is: undefined method `original_filename'' for "":String -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message...
2006 Jan 05
4
testing file uploads
Hi all, I was wondering about the class used when rails receives file uploads. Sometimes it appears to be a File, and other times it is a StringIO. Also it has methods such as original_filename that don''t appear to belong to either of these classes. I ask because I''m trying to work out how to test my fil upload related models and controllers. Is there some standardised way of creating a file upload mock object? Many thanks in advance. CHEERS> SAM
2007 Jul 05
2
undefined method `original_filename' for "random.jpg":String
...the one working correctly passes an actual file object whereas the broken one just passes a string. Here are the relevant files: models/attachment.rb: class Attachment < ActiveRecord::Base belongs_to :journal def attachment=(attachment_field) self.name = base_part_of(attachment_field.original_filename) self.content_type = attachment_field.content_type.chomp self.data = attachment_field.read end def base_part_of(file_name) name = File.basename(file_name) name.gsub(/[^\w._-]/, '''') end end controllers/journal_controller.rb: ... def new @journal = Jo...
2006 Aug 15
8
AGAIN: file object treated as string
I am trying to implement the uploading of a file to a remote server I get error while trying to write the file on the server. The error I get is the following: undefined method `rewind'' for #<String:0x2aaaad062eb8> It seems to be treating my file as a string instead of a File object. --------- Code is below ------------------ VIEW: <%=
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 Mar 13
2
Newbie: Can''t get file to upload
...39; %> <%= file_field ''eSimplyJob'', ''file'' %> <P> <%= submit_tag "Upload" %> </P> <%= end_form_tag %> Here''s my controller method: public def save_HTML @filename = @params[:eSimplyJob][:file].original_filename File.open("#{RAILS_ROOT}/htmlfiles/#{@filename}", "wb") do |f| f.write(@params[:eSimplyJob][:file].read) end puts "Finished with save_HTML" end When I execute the upload, I get the following error: undefined method `original_filename'' for...
2008 Jul 14
1
about string error for upload file in rails 2.1
...gt; ############################# In a model: class User < ActiveRecord::Base validates_format_of :photo,:with=>%r{\.(jpg|png|gif)$}i, :message=>"图片格式不正确" def file=(file_field) File.open("#{RAILS_ROOT}/public/images/users/#{file_field.original_filename}","wb+") { |i| i.write(file_field.read)} self.photo="/images/users/"+file_field.original_filename end end ############################## In a controller: class LoginController < ApplicationController def register @user=User.new(params[:user]) if par...
2006 Aug 01
3
Upload file to file system and sql insert date errors
...quot; end def self.save(upload) if !File.exists?("./traces/#{upload[''name'']}") Dir.mkdir("./traces/#{upload[''name'']}") end File.open("./traces/#{upload[''name'']}/#{upload[''file''].original_filename}", "wb") { |f| f.write(upload[''file''].read) } end end # contorller class UploadController < ApplicationController def create @upload = Upload.new(@params["upload"]) upload = Upload.insert(@params["upload"]) redirect_to :acti...
2006 May 04
3
File Upload problem when file is small, under 19k(read method returns nothing)
...hat when it is a StringIO rather than a temporary file nothing is returned from the read method. example code where "image" is the file upload form parameter, it works fine if image is over round 19k but is it is smaller then image.read returns nothing however the image.size and image.original_filename return the correct information. File.open(path_to_save_file, "wb") {|f| f.write(image.read) } All the best Ant -- Ant Peacocke www.levelsystems.net T: + 33 (0) 8 70 46 63 37 M: + 33 (0) 6 09 81 06 00
2008 Sep 02
2
Actionmailer - Multipart and Outlook?
...sage("ticket_email.text.plain.haml", :message => msg) part :content_type => "text/html", :body => render_message("ticket_email.text.html.haml", :message => msg) attachment :content_type => f.content_type, :body => contents, :filename => f.original_filename end Full Version (in case you wanted to take a look at it) def ticket_email(options) msg = options[:ticket_id] ? "#{options[:message]}<br /><br /><br />Please leave the [Ref: ##{options[:ticket_id]}] in your subject when replying, Thank you." : opt...
2006 May 29
3
File.size() on Uploaded Images Fail
...n 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 = newfile_field.content_type.chomp self.filesize = File.size(newfile_field) ### It fails on this line for images... end The error I get is: "can''t convert StringIO into String" I''m sure there''s an easier method/property to get the file...
2008 Jul 02
3
attachment in mail
How to do the attachment in mail like the yahoo and gmail does? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to
2007 Mar 11
4
Faking it... import local files into attachment_fu
...attachment_fu is still not happy. The Tempfile created via a multipart form and a browser has content_type set, as well as having the path be how the object is identified (i.e. - #<File:/tmp/file/path>). I feel like I''ve either reached a dead end and I have to explore setting size, original_filename, and content_type explicitly in the new method parameters or that I''m just bumping up against my ignorance and there is a better way I don''t know about. Recommendations? I noticed that there are mechanisms for this fake out in testing code, perhaps I''ll give them anothe...
2007 Dec 11
14
Attachment-fu + Story Runner
Hi all, I''m trying to run a Story Runner integration test that uploads a file through Attachment-fu. I''ve tried various ways of specifying the file data, from custom mocks: class MockFile < Struct.new (:original_filename, :read, :content_type); end fdata = MockFile.new "test_upload.txt", "Test Upload", "text/plain" to ''proper'' railsy stubs like: fdata = ActionController::TestUploadedFile.new("../spec/fixtures/ test_upload.txt", "text/plain") T...
2006 Mar 09
1
Rails File Upload w/ Ajax Update?
...d this issue? As a base, I''ve started with Typo''s Admin::ResourcesController and modified it as such: # controller def upload begin case request.method when :post file = params[:upload][:filename] @up = Resource.create(:filename => file.original_filename, :mime => file.content_type.chomp, :user => session[:user], :account => account, :created_at => Time.now) @up.write_to_disk(file) @messag...
2006 Apr 17
8
file upload
This is probably me having an issue with the mvc way of living.. .I''m used to perl/php scripting... I''ve got a photo blog I''m making... and in past iterations of this website, I''d just name the photos after the id of the entry. For instance: /photos/id.jpg /photos/id_thumb.jpg However, I''m having trouble finding an easy way to do this with rails.