File Column Plugin Extension Issue

February 11th, 2006

I have been using the great file column plugin by Sebastian Kanthak for a recent project. It makes file uploads and image manipulation insanely easy. During testing, however, I ran into one problem. I kept getting an argument error that the local file and the temp file had the same name. I tried several different images and discovered that the error only happened on photos with an uppercase extension. I changed the following line ...

FileUtils.mv(local_file_path, new_local_file_path) unless new_local_file_path == local_file_path

to the line below ...

FileUtils.mv(local_file_path, new_local_file_path) unless new_local_file_path.downcase == local_file_path.downcase

... and all was well in my little Rails world again. I tested several different photos and the error no longer occurred. This plugin is great so I'm hoping that if someone else is having the same problems and considering not using it, that they will find this post and change their mind.

9 Responses to “File Column Plugin Extension Issue”

  1. avatar stephane February 25th, 2006 4:47 pm

    Thank you, this post was very usefull for me, I had same problem (working on Mac OS X 10.4, ruby 1.8 and using the default case configuration). And this make me pass to my next bug :)

  2. Nice spotting…works well…for the others, file is:
    vendor/plugins/file_column/lib/file_column.rb

    cheers

  3. You need to add a ! otherwise it will happen.

  4. @edward – not sure what you are talking about.

  5. You are my hero.
    You save me years of research.
    Thanks a lot

  6. avatar Justin March 14th, 2007 7:47 pm

    The fix mentioned above didn’t work for us on a linux machine, so I added this

    filename = filename.downcase

    to the sanitize_filename method around like 714, so it looks like this…

    def self.sanitize_filename(filename)
    filename = filename.downcase
    filename = File.basename(filename.gsub(“\\”, “/”)) # work-around for IE
    filename.gsub!(/[^a-zA-Z0-9\.\-\+_]/,”_”)
    filename = “_#{filename}” if filename =~ /^\.+$/
    filename = “unnamed” if filename.size == 0
    filename
    end

  7. avatar spencer May 30th, 2007 10:43 pm

    you fail at life
    i hate you
    you are gay.

  8. avatar SF August 16th, 2007 1:08 am

    Thank you very much!

  9. avatar anand August 9th, 2009 1:19 am

    found a good solution here after googling http://bit.ly/yWmQx check out

About This Site

Addicted to New is the personal website of John Nunemaker (Noo-neh-maker), a Web Developer enamored of Ruby on Rails and a wide-eyed fan of all things new and cool.