Ruby on Rails
UploadingFilesWithFileColumn

Please flesh out this page.

Sebastian Kanthak has a useful file_column extension that makes handling file uploads really easy.
Also see:

Really really easy. My main contribution is that in order to put files from the server’s local filesystem into the database, you need to make them look like CGI uploaded files. Like so:

#config/environment.rb
...
require 'file_column_better'
...

#lib/file_column_better.rb
class File
    def original_filename
        path.split("/").pop
    end

    def size
        File.size(path)
    end

    def local_path
        path
    end
end

Update: Dec. 13, 2005

If you are having issues with file_column not assigning your uploaded files the correct rights, you can add the following line to file_column.rb at approximately line 202 to set the rights of the newly created file to whatever you’d like (0755 in this example):

File.chmod(0755, local_file_path)

It should go just below this block:

if file.respond_to?(:local_path) and file.local_path and File.exists?(file.local_path)
        FileUtils.copy_file(file.local_path, local_file_path)
      elsif file.respond_to?(:read)
        File.open(local_file_path, "wb") { |f| f.write(file.read) }
      else
        raise ArgumentError.new("Do not know how to handle #{file.inspect}")
      end

... And just above this block:

if @options[:fix_file_extensions]
        # try to determine correct file extension and fix
        # if necessary
        content_type = get_content_type((file.content_type.chomp if file.content_type))
        if content_type and @options[:mime_extensions][content_type]
          @filename = correct_extension(@filename,@options[:mime_extensions][content_type])
        end