search for: base_part_of

Displaying 12 results from an estimated 12 matches for "base_part_of".

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 May 29
3
File.size() on Uploaded Images Fail
...oaded 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 = 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...
2006 Aug 01
3
Upload file to file system and sql insert date errors
I''m trying to use one form to upload a file to the file system and insert a title and description field into the database. I have no problem uploading files to the file system using the code from http://wiki.rubyonrails.com/rails/pages/HowtoUploadFiles There are more fields on the form than need to be inserted into the database, name and file. I need to pull out these extra fields
2006 Jul 03
0
Multiple File Upload
...@params[:id]) begin project.attachments.create(params[:attachment]) rescue flash[:attachment_error] = "Error at Upload" end redirect_to :action => "edit_project", :id => project end attachment_model: ----------------- 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 edit_project.rhtml: ------------------- <%= form_tag(...
2006 Jul 04
0
Uploading files - getting size
..."attachment[title]" size="30" type="text" /> <input id="attachment_attachment" name="attachment[attachment]" size="30" type="file" /> In the Attachment-model is: def attachment=(attachment_field) self.name = base_part_of(attachment_field.original_filename) self.content_type = attachment_field.content_type.chomp #self.size = attachment_field.file.size self.data = attachment_field.read end def base_part_of file_name name = File.basename(file_name) name.gsub(/[^\w._-]/, '''') end In th...
2006 Jul 07
3
quick send_data question...
...rs to download files from the database but ran into a small problem, it seems that files upload fine but when they download only 64kb of the file is sent. I''m using the basic rails code from the Agile book: #upload code in my sheet model def file=(document_field) self.filename = base_part_of(document_field.original_filename) self.content_type = document_field.content_type.chomp self.data = document_field.read end def base_part_of(file_name) name = File.basename(file_name) name.gsub(/[^\w._-]/, '''') end #download in my application controller d...
2006 Mar 06
1
Uploaded File to Database
...he 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 model: class Document < ActiveRecord::Base has_many :comments def file=(file_field) self.filename = base_part_of(file_field.original_filename) self.content_type = file_field.content_type.chomp self.data = file_field.read end def base_part_of(file_name) name = File.basename(file_name) name.gsub(/[^\w._-]/, '''') end end The data column in the database is...
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 base_part_of(file_name) #if !file_name #end name = File.basename(file_name) name.gsub(/[^\w._-]/, '''') end and my form has an file input field...
2007 Jul 05
2
undefined method `original_filename' for "random.jpg":String
...t;asdf"} As you can see, 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.r...
2006 Jul 18
0
ffmpeg and IO.popen
...{opts}?, ?w?)#{ |io| io.puts stream} end def myfile=(myfile_field) if myfile_field and myfile_field.length > 0 encodeVideo ?-i /tmp/Student_Interviews.mov -ar 22050 -ab 64 -f flv -s 320?240 /tmp/Student_Interviews.flv?#, myfile_field.read #self.data = myfile_field.read self.filename = Myfile.base_part_of(myfile_field.original_filename) + Date.to_s filesize = (myfile_field.length / 1000).to_i if filesize == 0 self.filesize = 1 # a file of 0 KB doesn?t make sense else self.filesize = filesize end end end -- Posted via http://www.ruby-forum.com/.
2006 Feb 06
2
File_field and Firefox
...b: def upload=(upload_field) self.filename=upload_field self.content_type=MIME::Types.type_for(upload_field) File.open(upload_field, "rb") { |f| #ERROR HERE self.filename=File.basename(upload_field) self.content=f.read } end def base_part_of(file_name) name=File.basename(file_name) name.gsub(/[^\w._-]/,'''') end As far as i know im not calling any filename-modder in the model, so maybe the problem is in the view? Thanks in advance for all helps... -- Maurizio Marek idnondisponibile@fastwebnet.it
2005 Sep 07
0
model constructor errors.
...ependent => true belongs_to :user validates_presence_of :title validates_presence_of :description, :on => :update acts_as_taggable def picture=(picture_field) logger.debug "in picture method" ## DEBUGGING @local_path = picture_field.local_path @filename = base_part_of(picture_field.original_filename) @extension = @filename.split(''.'').pop if @extension == "jpeg" @extension = "jpg" ## convention end @content_type = picture_field.content_type.chomp @size = picture_field.size picture_field.rew...