【问题标题】:Shrine Image uploader not mounted correctly神社图片上传器未正确安装
【发布时间】:2020-02-24 20:50:38
【问题描述】:

我正在尝试遵循本教程https://gorails.com/forum/direct-file-uploads-to-s3-part-2-example-gorails,在加载我的本地服务器时,它会吐出这个错误:

 routing/mapper.rb:613:in `mount': A rack application must be specified (ArgumentError)

这是我的路线:

Rails.application.routes.draw do
 root to: "photos#index"
 resources :photos

 mount ImageUploader::UploadEndpoint, at: "/images/upload"
end

如果有人需要它,我的神殿.rb 初始化器

require "shrine/storage/s3"

 s3_options = {
  access_key_id: "MY_ACCESS_KEY",
  secret_access_key: "MY_SECRET_KEY",
  region: "S3_REGION",
  bucket: "S3_BUCKET",
}

Shrine.storages = {
  cache: Shrine::Storage::S3.new(prefix: "cache", **s3_options),
  store: Shrine::Storage::S3.new(prefix: "store", **s3_options),
}

Shrine.plugin :activerecord
Shrine.plugin :upload_endpoint
Shrine.plugin :presign_endpoint
Shrine.plugin :restore_cached_data

我们将不胜感激任何和所有的帮助!

【问题讨论】:

    标签: amazon-s3 ruby-on-rails-5 shrine


    【解决方案1】:

    Shrine::UploadEndpoint 类是带有旧 direct_upload 插件的 Rack 应用程序。使用upload_endpoint 插件,您现在可以调用Shrine.upload_endpoint 方法为选定的存储创建一个Rack 应用程序:

    mount ImageUploader.upload_endpoint(:cache), at: "/images/upload"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-12
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 2016-07-21
      相关资源
      最近更新 更多