Hi ! My app is hosted on DreamHost, and when I upload files (images actually), I want to serve them back to the user. The application is running under FCGI as a specific user. Since these are static files, Apache is trying to serve them, but it can''t see the files because they have mode 0600. All middle-level directories have the same access permissions. That''s problem #1. Problem #2 is that the files might have non ASCII characters in their filename. I''d like to be able to specify a mapping function that maps the file''s name to something else. Either a Proc or a method symbol, just like validate. #1 is more important to me right now. The other is a feature request :) Bye ! François
François Beausoleil wrote:> Hi ! > > My app is hosted on DreamHost, and when I upload files (images > actually), I want to serve them back to the user. The application is > running under FCGI as a specific user. Since these are static files, > Apache is trying to serve them, but it can''t see the files because they > have mode 0600. All middle-level directories have the same access > permissions.Any particular reason File.chmod(0644, filename) wouldn''t do what you''re after?> > That''s problem #1. Problem #2 is that the files might have non ASCII > characters in their filename. I''d like to be able to specify a mapping > function that maps the file''s name to something else. Either a Proc or > a method symbol, just like validate.If it doesn''t have to be human-readable, you could base64 encode it with Base64.encode64(filename), which would have the advantage that you could just decode it to get back to the original. No idea if this is any help whatsoever, just the first things that popped into my head :-) -- Alex
rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
2005-Sep-08 15:08 UTC
Re: file_column permission problem
Alex Young said the following on 2005-09-08 10:44:> Any particular reason File.chmod(0644, filename) wouldn''t do what you''re > after?Exactly what I was looking for. Thank, Alex. I just thought there might be a way to tell the server to inherit file permissions. I''ll just chmod everything I need. Bye ! François
Hello François!> That''s problem #1. Problem #2 is that the files might have non ASCII > characters in their filename. I''d like to be able to specify a mapping > function that maps the file''s name to something else. Either a Proc or > a method symbol, just like validate.The filenames should not have non ASCII-characters in them, it''s just a little typo. Just replace the following line in file_column.rb in the method self.sanitize_filename(filename) filename.gsub(/[^a-zA-Z0-9\.\-\+_]/,"_") with filename.gsub!(/[^a-zA-Z0-9\.\-\+_]/,"_") (gsub! instead of gsub) Then everything works as expected. I have sent a diff to Sebastian, it will surely be corrected in the next version! Bye, Michael
Hi, On 9/8/05, Michael Raidel <michael.raidel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The filenames should not have non ASCII-characters in them, it''s just > a little typo. Just replace the following line in file_column.rb in > the method self.sanitize_filename(filename) > > filename.gsub(/[^a-zA-Z0-9\.\-\+_]/,"_") > with > filename.gsub!(/[^a-zA-Z0-9\.\-\+_]/,"_") > (gsub! instead of gsub) > > Then everything works as expected. I have sent a diff to Sebastian, it > will surely be corrected in the next version!thanks for the fix, I will certainly include this :) I was travelling for the past two weeks and got a lot of diffs while I was away so expect a new version soon... Sebastian