Project

General

Profile

Custom folder for attachments. How?

Added by Anonymous about 16 years ago

I'd like to store the attachments in another folder than the standard folder (REDMINE/files).

There is a class variable 'storage_path' in the Attachment class and I suppose that I could set it in the 'environment.rb' file. But it somehow doesn't work ;-(

Please help. Thank you,
Hans-Peter

PS: Somewhat related: would it be possible to use a database.yml config file which is located somewhere else than the default place (REDMINE/config)? Thanks!


Replies (6)

RE: Custom folder for attachments. How? - Added by Thomas Löber about 16 years ago

I also don't know if it is possible to set the storage_path via environment.rb but on Unix you can of course use a symbolic link to another directory. That applies to database.yml as well.

RE: Custom folder for attachments. How? - Added by Anonymous about 16 years ago

Symbolic links are perfect. Thanks for this idea!

RE: Custom folder for attachments. How? - Added by Tony Arnold over 15 years ago

But not the ideal answer to this problem - see #2231

RE: Custom folder for attachments. How? - Added by Anonymous over 15 years ago

And as I later found out symbolic links are also not ideal when updating Redmine through svn: one has to temporarly rename the link name. But at least it is possible.

RE: Custom folder for attachments. How? - Added by Frédéric PLEWNIAK over 13 years ago

As it looks like this is still a problem in version 1.0.2 I used the following trick in order to define a custom folder for attachments without any symbolic link :

1) in config/environments/production.rb
I added te following line :
STORAGE_ROOT = "/my/storageroot/"

2) and in app/models/attachment.rb
I replaced

@@storage_path = "#{RAILS_ROOT}/files"

by

@@storage_path = "#{STORAGE_ROOT}/files"

No big deal, isn't it ?
I'll just have to remember that next time I upgrade... ;o)

RE: Custom folder for attachments. How? - Added by Thomas Löber over 13 years ago

I created a small plugin to not have to patch the files in app (please see attachment).

After unpacking the plugin to vendor/plugins you only have to add something like this to config/environments/production.rb:

# Plugin redmine_attachment_storage
REDMINE_ATTACHMENT_STORAGE_CONFIG = {
  :path => "/home/abc/files",
}

redmine_attachment_storage.zip (11.6 KB) redmine_attachment_storage.zip Redmine plugin: attachment_storage
    (1-6/6)