[Mongrel] Mongrel and umask for uploaded files

Mike Garey random49k at gmail.com
Fri Sep 8 14:24:59 EDT 2006


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


More information about the Mongrel-users mailing list