- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试让 CKEditor 与 Carrierwave 和 Cloudinary 一起工作。到目前为止,带有常规文件上传字段的非 CKEditor 启用 View 与 Carrierwave 和 Cloudinary 完美配合。但是,当我尝试在 CKEditor 中上传文件并“将其发送到服务器”时,我收到了 NoMethodError - undefined method 'each' for "image/jpeg":String:
在从 CKEditor 类中删除本地存储配置之前,它正在工作,但将文件保存在本地。
这是我当前的 CKEditor 上传器:
class CkeditorAttachmentFileUploader < CarrierWave::Uploader::Base
include Cloudinary::CarrierWave
include Ckeditor::Backend::CarrierWave
def extension_white_list
Ckeditor.attachment_file_types
end
end
Started POST "/ckeditor/pictures?CKEditor=subsection_content&CKEditorFuncNum=3&langCode=en&authenticity_token=5Bt06UwjUD%2FEdLFANBmZojdv8Hvn2GbQRLvC6h11Dd8%3D" for 127.0.0.1 at 2013-06-20 15:44:18 -0700
Processing by Ckeditor::PicturesController#create as HTML
Parameters: {"upload"=>#<ActionDispatch::Http::UploadedFile:0x007ff742c77018 @original_filename="pic1.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"upload\"; filename=\"pic1.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<Tempfile:/var/folders/0t/l1qc3j596v77_z3s8f2pm75w0000gn/T/RackMultipart20130620-18566-i0av53>>, "CKEditor"=>"subsection_content", "CKEditorFuncNum"=>"3", "langCode"=>"en", "authenticity_token"=>"5Bt06UwjUD/EdLFANBmZojdv8Hvn2GbQRLvC6h11Dd8="}
(0.4ms) BEGIN
(0.4ms) ROLLBACK
Completed 500 Internal Server Error in 4ms
NoMethodError - undefined method `each' for "image/jpeg":String:
(gem) cloudinary-1.0.59/lib/cloudinary/carrier_wave/process.rb:100:in `block in transformation'
ckeditor_picture_uploader.rb
文件:
# encoding: utf-8
class CkeditorPictureUploader < CarrierWave::Uploader::Base
include Ckeditor::Backend::CarrierWave
include Cloudinary::CarrierWave
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
# storage :file
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
# def store_dir
# "uploads/ckeditor/pictures/#{model.id}"
# end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
[:extract_content_type, :set_size, :read_dimensions].each do |method|
define_method :"#{method}_with_cloudinary" do
send(:"#{method}_without_cloudinary") if self.file.is_a?(CarrierWave::SanitizedFile)
{}
end
alias_method_chain method, :cloudinary
end
process :read_dimensions
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fill => [118, 100]
end
version :content do
process :resize_to_limit => [800, 800]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
Ckeditor.image_file_types
end
end
最佳答案
尝试将以下代码添加到您的 CkPictureUploader/CkeditorAttachmentFileUploader:
[: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_chain method, :cloudinary
end
关于ruby-on-rails - CKEditor Carrierwave Cloudinary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17225138/
有没有办法将图片批量上传到我的云帐户? 我希望一次导入 100 张 3MB 的图像。 谢谢你。 最佳答案 您可以使用 Cloudinary 的上传 API 来一张一张上传图片。 Here is a s
我正在尝试进行 cloudinary 未签名上传。我有 html 中的文件标签,现在我尝试通过 JavaScript 初始化它。但是,我收到了奇妙的错误,即状态 $.cloudinary.unsign
我正在从浏览器直接向 Cloudinary 进行未签名的上传,并试图显示大型上传的进度。 我正在使用 cloudinary node library . 有没有什么方法可以在浏览器中使用 cloudi
我正在尝试将图像从 android 上传到 cloudinary,但我遇到了很多问题。我在 onCreate 方法中像这样初始化了 MediaManager: Map config = new Has
我按照教程使用 Cloudinary Widget 上传多张图片。我想使用签名上传。 https://cloudinary.com/documentation/upload_widget#signed
我已尽力使这段代码正常工作,但是,唉!肯定有什么问题。我试图列出 Cloudinary 中的所有 public_ids 。但它总是打印 null。下面是代码 - import java.util.Ha
这是一个简单的模型: 类产品(模型。模型): caption = models.CharField(max_length=1000) description=models.TextField() su
我是 cloudinary 和 Angular 的新手。我一直在寻找一种通过不使用 SDK 将图像上传到 cloudinary 的方法,因为 cloudinary 为我们提供了使用 post API
我已经在我的项目中安装了 Cloudinary sdk,但是当尝试从 sdk 创建变量时,出现以下错误 - 问题是我已经在我的项目中安装了cloudinary sdk,它位于我的“node_modul
我正在尝试基于此代码笔示例构建一个简单的 Cloudinary 图像上传:https://codepen.io/team/Cloudinary/pen/QgpyOK -- 我已经将它转换为与 fetc
有人可以告诉我如何将 Cloudinary 安装到我的 Strapi 应用程序中,我像文档所说的那样安装了插件,但该插件根本没有出现在我的项目中。谁能告诉我我做错了什么 最佳答案 Strapi 文档中
我想建立一个包含很多图像的网站,并因此对图像进行处理,例如亚马逊,ebay,flipkart等。建议我使用Cloudinary,Imgix等服务来调整图像大小,因为最好存储每个图像的一个版本,尽管我需
我正在使用 JavaScript 以未签名模式上传图像。生成的图像是空白图像,或者我可以说是填充黑色的图像。不知道出了什么问题。代码如下: var xhttp = new XMLHttpRequest
我正在实现 Cloudinary Jquery 上传。从我的文件上传网页,如果我浏览到另一个网站(google.com 或任何外部网站),然后单击浏览器上的后退按钮进入同一文件上传页面,上传将失败。
我用来将书籍封面上传到 Cloudinary 的表单上有一个 input type='file'。不过,我也希望不允许上传图像,即当表单提交时,没有向 input type='file' 提供文件。
$http({method: 'POST', url: $rootScope.CLOUDINARY_CONFIG.upload_url, data : { file : c
我正在使用 Express.js 编写 REST API。该API需要接受来自客户端的视频文件并将其上传到cloudinary。当我使用 api 将文件返回给客户端(作为测试)时,一切正常。当我尝试将
我的代码在下面。我尝试通过 java 将图像上传到 cloudinary 但没有上传它显示以下错误 Exception in thread "main" java.lang.UnknownError:
这是我第一次在这里发帖提问。我正在构建一个具有图像上传功能的 meteor 应用程序。我找到了 meteor 的 cloudinary 包 https://github.com/Lepozepo/cl
我想将图像上传到 Cloudinary,使用cordova 相机插件直接从 Ionic 中的相机拍摄。我收到代码 1 的错误,显示消息“上传预设必须在未签名上传的白名单中”。 如何解决此错误。请帮助。
我是一名优秀的程序员,十分优秀!