我正在尝试在Rails Admin中使用Ckeditor,其中我使用Carrierwave和云存储作为Cloudinary。在进行了我看到的所有设置之后,CKeditor可以将文件保存在本地存储上,然后它会创建一个Cloudinary URL,实际上应该在其中存储图像。但问题是图像没有从本地文件夹上传到Cloudinary,而我的简单文件上传工作正常,没有任何问题。
我这里还有一个问题--当我使用Cloudinary时,存储名称应该是什么?至于文件和亚马逊S3,我们有文件和s3的名称。
请回复。
谢谢
发布于 2018-06-09 03:29:04
我对ckeditor也有意见。编辑您的CkeditorAttachmentFileUploader
,使其如下所示:
class CkeditorAttachmentFileUploader < CarrierWave::Uploader::Base
include Ckeditor::Backend::CarrierWave
include Cloudinary::CarrierWave
[:extract_content_type, :extract_size, :extract_dimensions].each do |method|
define_method :"#{method}_with_cloudinary" do
send(:"#{method}_without_cloudinary") if self.file.is_a?(CarrierWave::SanitizedFile)
{}
end
alias_method :"#{method}_without_cloudinary", method
alias_method method, :"#{method}_with_cloudinary"
end
def extension_white_list
Ckeditor.attachment_file_types
end
end
在那之后,你会发现另一个错误。我发现在Ckeditor::AssetResponse#asset_url方法中,asset
对象不会重新加载,因此asset.content_url
将始终为空,从而导致错误。我是这样修复的:
class Ckeditor::Picture < Ckeditor::Asset
...
def url_content
url(:content) || begin
if persisted?
reload
url(:content)
end
end
end
end
如果你有Ckeditor::AttachmentFile
类,它也是一样的。
发布于 2013-04-12 10:04:22
确保删除对CarrierWave.config.storage = :file的所有引用
如果上传不起作用,您需要在以下几个地方执行此操作:
在/config/initializers/carrierwave_init.rb中,删除对以下内容的所有引用:
config.storage = :file
在你的上传程序中删除和引用排序:
storage :file
https://stackoverflow.com/questions/12555075
复制相似问题