Forum: Radiant CMS AssetManager Controlling Where Files are Saved

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
78cb50691f1df8fd06c2cf26c524e598?d=identicon&s=25 Michael Jones (Guest)
on 2007-02-05 23: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 =>
'public/images',
: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
public/images/3/*.jpg

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 :
self).attachment_options[:file_system_path]
  #File.join(RAILS_ROOT, file_system_path,
attachment_path_id,thumbnail_name_for(thumbnail))
  File.join(RAILS_ROOT, file_system_path, thumbnail_name_for(thumbnail))
 end

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!

Thanks-
Michael
This topic is locked and can not be replied to.