File upload and permissions


I upload a file with this model :

class Match < ActiveRecord::Base
  belongs_to :contest
  belongs_to :user
  has_many :comments

def replay=(uploaded_file)
    @uploaded_file = uploaded_file
    @filename = sanitize_filename(@uploaded_file.original_filename)

  def after_create
    if !File.exists?(File.dirname(self.path_to_file))
    if @uploaded_file.instance_of?(Tempfile)
      FileUtils.copy(@uploaded_file.local_path, self.path_to_file)
    else, "wb") { |f|
f.write( }
      File.chmod(755, self.path_to_file)
    write_attribute(:replay, self.path_to_file)

  def after_destroy
    if File.exists?(self.replay)

  def simple_path

  def path_to_file

  def sanitize_filename(file_name)
    # get only the filename, not the whole path (from IE)
    just_filename = File.basename(file_name)
    # replace all none alphanumeric, underscore or perioids with

The problem is that I can't download the file. The FileUtils.chmod
won't work.
I use apache/passenger.

the file directory :
drwxrwxr-x 4 www-data sobert 4096 oct 16 13:39 files

and in file directory :
drwxr-xr-x 2 sobert sobert 4096 oct 16 13:43 13

and in 13 directory :
-rw------- 1 sobert sobert 275955 oct 16 13:43

How to set the permissions right In order to allow download ?

Thanks !