raulanatol / el_finder_s3

Ruby gem to provide server side connector to elFinder using AWS S3 like a container
MIT License
1 stars 7 forks source link

Bucket content is not loaded. #4

Open aryalsan opened 6 years ago

aryalsan commented 6 years ago

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.

screen shot - - at
raulanatol commented 6 years ago

Hi @aryalsan,

I'm so sorry for the delay in my reply. I've got this project out of maintenance and I had forgotten. I need to dust off and I will say anything as some as possible.

Regards.

aryalsan commented 6 years ago

Hi @raulanatol

I think i made the fix for it. Its working now. I don't know if it is the best option. Is it possible to work together on this project. I want to add other modifications.

 include ElFinderS3::Action

  def elfinder
    h, r = ElFinderS3::Connector.new(
      :mime_handler => ElFinderS3::MimeType,
      :root => '/',
      :url => 'CDN_BASE_PATH'
      :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 => 'AWS_REGION',
        :access_key_id => 'ACCESS_KEY_ID',
        :secret_access_key => 'SECRET_ACCESS_KEY',
        :cdn_base_path => 'CDN_BASE_PATH'
      }
    ).run(params)
    headers.merge!(h)

    if r.empty?
      (render :nothing => true) and return
    end
    render :json => r, :layout => false
  end
raulanatol commented 6 years ago

Hi @aryalsan!

Sure, please send me a pull request of any change that you want.

Thx! Regards.