I am using Elfinder Rails for Media Manger in my application. I am working on to store the media files to Amazon S3 storage. I try to use the gem el_finder_s3. I created bucket and provided all the configurations like.
def elfinder
ElFinderS3::Connector.new(
:mime_handler => ElFinderS3::MimeType,
:root => '/',
:url => 's3.ap-southeast-1.amazonaws.com',
:thumbs => true,
:thumbs_size => 100,
:thumbs_directory => 'thumbs',
:home => t('admin.media.home'),
:original_filename_method => lambda { |file| "#{File.basename(file.original_filename, File.extname(file.original_filename)).parameterize}#{File.extname(file.original_filename)}" },
:default_perms => {:read => true, :write => true, :rm => true, :hidden => false},
:server => {
:bucket_name => 'bucket_name',
:region => 'ap-southeast-1',
:access_key_id => 'acces_key',
:secret_access_key => 'secret_key',
:cdn_base_path => 's3.ap-southeast-1.amazonaws.com'
}
).run(params)
end
Rails application is connect with S3 but elfinder doesn't show the file contents. I checked the bucket, thumb folder was created but elfinder was unable to load the contents.
Please help me to fix it.
It is fixed with the update of the above script. Here is the updated script.
def elfinder
h, r = ElFinderS3::Connector.new(
:mime_handler => ElFinderS3::MimeType,
:root => '/',
:url => 's3.ap-southeast-1.amazonaws.com',
:thumbs => true,
:thumbs_size => 100,
:thumbs_directory => 'thumbs',
:home => t('admin.media.home'),
:original_filename_method => lambda { |file| "#{File.basename(file.original_filename, File.extname(file.original_filename)).parameterize}#{File.extname(file.original_filename)}" },
:default_perms => {:read => true, :write => true, :rm => true, :hidden => false},
:server => {
:bucket_name => 'bucket_name',
:region => 'ap-southeast-1',
:access_key_id => 'acces_key',
:secret_access_key => 'secret_key',
:cdn_base_path => 's3.ap-southeast-1.amazonaws.com'
}
).run(params)
headers.merge!(h)
if r.empty?
(render :nothing => true) and return
end
render :json => r, :layout => false
end