Writing an email file attachment to the filesystem

I’m having some difficulty writing an email file attachment to the
filesystem.

I have the following line in my /etc/aliases

webname: “| /usr/bin/ruby /home/webname/webapp/script/runner
‘AssetSubmitHandler.receive STDIN.read’”

Everything works up to this point, it picks up the email and tries to
process it.

When I go to write the file using (in my AssetSubmitHandler class):

File.open(base_dir+asset.path,File::CREAT|File::TRUNC|File::WRONLY,0666){
|f|
f.write(attachment.read)
}

I get the following error:

/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/runner.rb:27:
/home/webname/webapp/script/…/config/…/app/models/asset_submit_handler.rb:20:in
`initialize’: Permission denied -
/home/webname/public_html/assets/1153841511581165.gif (Errno::EACCES)

pwd: /home/webname/www
ls -la: drw-rw-rw- 2 webname webname 4096 Jul 18 15:17 assets/