So any files that are uploaded through my form are getting the following mode: -rw------- I need them to have: -rw-r--r-- I''ve tried setting the umask in a script file called set_umask.rb as follows: File.umask(022) and then starting mongrel using: mongrel_rails start -m config/mime.types -S set_umask.rb but it doesn''t seem to change the mode that the files are created with.. I''ve also tried putting "File.umask(022)'' inside environment.rb but that doesn''t make a difference. To handle uploads, I have a resource model which does the following in the before_create filter: def before_create return FileUtils.copy( @uploaded_file.local_path, self.path_to_file) if @uploaded_file.instance_of?(Tempfile) # else File.open(self.path_to_file, "w") { |f| f.write(@uploaded_file.read) } end If anyone has any other hints for how to change the umask, please let me know, this is driving me crazy! Thanks, Mike
Hi! On Tue, Sep 05, 2006 at 05:32:41PM -0400, Mike Garey wrote:> So any files that are uploaded through my form are getting the following mode: > > -rw------- > > I need them to have: > > -rw-r--r-- > > I''ve tried setting the umask in a script file called set_umask.rb as follows: > > File.umask(022) > > and then starting mongrel using: > > mongrel_rails start -m config/mime.types -S set_umask.rb > > but it doesn''t seem to change the mode that the files are created > with.. I''ve also tried putting "File.umask(022)'' inside > environment.rb but that doesn''t make a difference.I''ve had similar problems, in my case the umask I set was used when uploading from Firefox/linux, but not when uploading from Firefox/windows. Weird, but manually changing the permissions after copying the file finally fixed this. File.chmod(0644, self.path_to_file) after the File.open line should do the trick for you. Jens> > To handle uploads, I have a resource model which does the following in > the before_create filter: > > def before_create > return FileUtils.copy( @uploaded_file.local_path, > self.path_to_file) if @uploaded_file.instance_of?(Tempfile) > # else > File.open(self.path_to_file, "w") { |f| f.write(@uploaded_file.read) } > end > > > If anyone has any other hints for how to change the umask, please let > me know, this is driving me crazy! Thanks, > > Mike > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users-- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66
On 9/6/06, Jens Kraemer <kraemer at webit.de> wrote:> Hi! > On Tue, Sep 05, 2006 at 05:32:41PM -0400, Mike Garey wrote: > > So any files that are uploaded through my form are getting the following mode: > > > > -rw------- > > > > I need them to have: > > > > -rw-r--r-- > > > > I''ve tried setting the umask in a script file called set_umask.rb as follows: > > > > File.umask(022) > > > > and then starting mongrel using: > > > > mongrel_rails start -m config/mime.types -S set_umask.rb > > > > but it doesn''t seem to change the mode that the files are created > > with.. I''ve also tried putting "File.umask(022)'' inside > > environment.rb but that doesn''t make a difference. > > I''ve had similar problems, in my case the umask I set was used when > uploading from Firefox/linux, but not when uploading from > Firefox/windows. Weird, but manually changing the permissions after > copying the file finally fixed this. > > File.chmod(0644, self.path_to_file) > after the File.open line should do the trick for you.thanks for the answer Jens, I ended up doing the same thing as you and it works fine now.. Thought there might be an easier way to do this, such as setting a global umask, but I guess I''ll just stick to using this method until I find another way to do it. Thanks again, Mike