加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Paperclip Gem – “图像的内容不是它们报告的

发布时间:2020-12-17 04:15:54 所属栏目:百科 来源:网络整理
导读:该网站的功能是发布博客帖子.它在 Windows 7上本地运行.我尝试过Paperclip gem(版本4.2.4和4.3),服务器进入cmd的无限循环(4.2.4上没有发生但仍然出错).我做了捆绑安装,它肯定是安装的. 的Gemfile: gem "paperclip","~ 4.3" 这是模型: class Post ActiveRec
该网站的功能是发布博客帖子.它在 Windows 7上本地运行.我尝试过Paperclip gem(版本4.2.4和4.3),服务器进入cmd的无限循环(4.2.4上没有发生但仍然出错).我做了捆绑安装,它肯定是安装的.

的Gemfile:

gem "paperclip","~> 4.3"

这是模型:

class Post < ActiveRecord::Base

    has_attached_file :image,:default_url => ":style/rails1.jpg"
    validates_attachment_content_type :image,:content_type => /Aimage/.*Z/

end

这是我在尝试提交图像(png或jpg)时遇到的错误:

Image has contents that are not what they are reported to be

我是新手,所以详细的解释将不胜感激.我在这里阅读了一些其他修复但没有任何效果.

解决方法

找出一个临时解决方案:

添加此文件

配置/初始化/ paperclip_media_type_spoof_detector_override.rb

require 'paperclip/media_type_spoof_detector'
module Paperclip
  class MediaTypeSpoofDetector
    def spoofed?
      false
    end
  end
end

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读