# Attachment\_fu and filenames on a linux machine

**URL:** <https://www.ruby-forum.com/t/attachment-fu-and-filenames-on-a-linux-machine/129172>\
**Category:** Rails\
**Created:** [February 15, 2008, 2:41am UTC](https://www.ruby-forum.com/t/attachment-fu-and-filenames-on-a-linux-machine/129172 "2008-02-15T02:41:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sikanrong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@sikanrong](https://www.ruby-forum.com/u/sikanrong)\
**Post date:** [February 15, 2008, 2:41am UTC](https://www.ruby-forum.com/t/attachment-fu-and-filenames-on-a-linux-machine/129172/1 "2008-02-15T02:41:18Z")

</div>

So, I’m seeing something fully weird trying to use attachment\_fu on a  
linux server, and I know Rick O. is chilling somewhere on this forum

- so I’m hoping he can poke his head out to help me here (although  
honestly anyone with an answer will make me equally happy)

The deal is as follows: We’re developing an application which lets users  
upload (using attachment fu) any old filetype they want, and then to  
re-download it. For the most part, this is working great UNTIL we upload  
to our ubuntu linux test slice. Just to clarify, I’m on a mac (so UNIX  
generally) and I’ve NEVER seen the linux slice act too much differently  
than what I see on my own machine. In this case (for some reason), it  
is. When I upload a file on my mac environment called “Engr Update 10760  
copy.ppt” - i get the expected filename back when I re-download:  
“Engr\_Update\_10760\_copy.ppt”: the underscores come from the “def  
sanitize\_filename” in attachment\_fu.rb. So, by the same logic, on my  
linux slice when I up/download a file i should get the same thing.  
Somehow, I upload the file, and when I get it back, the name has changed  
to “\_Engr”. The file is in-tact, but since it’s lopping off the  
finishing part of the filename (namely the .xxx extension), my windows  
users are getting screwed. This only happens when I upload files with  
spaces in the filename, and for some reason I just _can’t_ get it to  
stop happening, unless I overwrite the “thumbnail\_name\_for” method in my  
model such that:

def thumbnail\_name\_for(thumbnail = nil)  
extension = filename.scan(/.\w+$/)  
return “#{self.id}#{extension}”  
end

this way the linux server can’t get ‘confused’ by the original\_filename  
(specifically the spaces in it) and lop off my file extensions! At the  
same time, my company would like to preserve SOME form of the original  
filename (for our user’s convenience) - and I’m just spent on it.

But my natural coder instinct tells me one thing: I can’t be the first  
person to have this happen!! Ubuntu: most common linux distro in 2008.  
Attachment\_fu: most common image uploading plugin for RoR. Advice,  
anyone?

---

<div class="post-metadata">

**Author:** ![sikanrong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@sikanrong](https://www.ruby-forum.com/u/sikanrong)\
**Post date:** [February 15, 2008, 5:57pm UTC](https://www.ruby-forum.com/t/attachment-fu-and-filenames-on-a-linux-machine/129172/2 "2008-02-15T17:57:46Z")

</div>

actually, the fix i listed up there doesn’t even work on my linux slice  
( just figured it would) , i just get back (ONLY on the ubuntu slice)  
the id number with no extension (still, no extension!)
