Elfinder Rails 和 Amazon S3

Elfinder Rails and Amazon S3

我在我的应用程序中使用 Elfinder Rails for Media Manger。我正在努力将媒体文件存储到 Amazon S3 存储中。我尝试使用gemel_finder_s3。我创建了存储桶并提供了所有配置,例如。

  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 应用程序与 S3 连接,但 elfinder 不显示文件内容。我检查了存储桶,thumb 文件夹已创建,但 elfinder 无法加载内容。

请帮我解决一下。

已通过上述脚本的更新修复。这是更新后的脚本。

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