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.
If you enjoyed this post, get free updates by email or RSS.
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 :)
Nice spotting…works well…for the others, file is:
vendor/plugins/file_column/lib/file_column.rb
cheers
You need to add a ! otherwise it will happen.
@edward – not sure what you are talking about.
You are my hero.
You save me years of research.
Thanks a lot
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
you fail at life
i hate you
you are gay.
Thank you very much!
found a good solution here after googling http://bit.ly/yWmQx check out