Forum: Radiant CMS AssetManager Controlling Where Files are Saved

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Michael J. (Guest)
on 2007-02-06 00:00
(Received via mailing list)
I wanted to put this out there to possibly help someone and also to
get any feedback if this is the wrong way to do it...

By default the AssetManager saves uploaded files in public/assets/ID/

I wanted files to be saves in the public/images directory.

To do that edit asset.rb the acts_as_attachment line to be:

acts_as_attachment :storage => :file_system, :file_system_path =>
:max_size => 2048.kilobytes, :content_type => :image,
:thumbnails => { :normal => '600x400', :thumbnail => '100x100', :icon
=> '42x42' }

Note I added:
":file_system_path => 'public/images',"

This got the images saved in the public/images directory however it
still created a directory for the ID so images were stored like

To get them in the 'images' directory override the "full_filename"
method to asset.rb:

 def full_filename(thumbnail = nil)
  file_system_path = (thumbnail ? thumbnail_class :
  #File.join(RAILS_ROOT, file_system_path,
  File.join(RAILS_ROOT, file_system_path, thumbnail_name_for(thumbnail))

Note I commented out the first File.join line and aded a new one minus
the "attachment_path_id"

Hope this helps and again if this is a bad idea someone please tell me!

This topic is locked and can not be replied to.