PaperClip 6.0不支持在rails中上传base64编码的文件



我使用的是回形针6.0.0 gem,我希望在rails应用程序中支持使用数据URI或base64编码字符串上传文档。

推荐人:https://github.com/thoughtbot/paperclip/issues/2575

我的应用程序/initializers/paperclip.rb有以下内容:

回形针:DataUriAdapter.register

我的模型是这样的:

class Document < ApplicationRecord
has_attached_file :doc, :restricted_characters => nil
end

我的参数如下:

doc => { data:application/octet-stream;name=testing.json.jbuilder;base64,anNvbi50eXBlICdTaW5nbGVDb2x1bW4nDQpqc29uLnN0eWxl ..... }

我在控制台中得到以下错误:

Paperclip::AdapterRegistry::NoHandlerError(找不到"数据:应用程序/八位字节流;名称=testing.json.jbuilder;base64,anNvbi50eXBlICdTaW5nbGVDb2x1bW4nDQpqc29uLn0eWxl……"的处理程序(

不确定它是否与新版本有关。。。

谢谢。

他们确实支持它,但您必须通过在config/initializers/paperclip.rb中添加Paperclip::DataUriAdapter.register来启用配置。

请参阅此处的问题:https://github.com/thoughtbot/paperclip/issues/2575.

最新更新