I'm using paperclip to upload files of the mime-type "application/octet-stream", but they aren't validating properly.
In the controller, when I call replay.save!
, I get the following error:
Validation failed: r_file has contents that are not what they are reported to be, r_file is invalid, r_file content type is invalid
Here is the model:
class Replay < ApplicationRecord
has_attached_file :r_file
validates_attachment_content_type :r_file, content_type: { content_type: "application/octet-stream" }
end
and the create method in the replay controller:
def create
@replay = Replay.new(replay_params)
if @replay.save
# This never runs because it won't validate.
puts "REPLAY SAVED."
redirect_to @replay
else
puts "REPLAY NOT SAVED."
render 'new'
end
end
I checked the mime-type of the file I'm trying to upload, and it is definitely of type "application/octet-stream"
. Is Paperclip just reading the file type incorrectly?
EDIT:
Here is the schema:
ActiveRecord::Schema.define(version: 20161203161351) do
create_table "replays", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "map"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "r_file_file_name"
t.string "r_file_content_type"
t.integer "r_file_file_size"
t.datetime "r_file_updated_at"
end
end
file
check github.com/thoughtbot/paperclip/issues/1530 – Officiaryapplication/x-bittorrent
but mime type treat it asoctet-stream
– Officiaryapplication/x-bittorrent
and that didn't work either. – Intendmentapplication/*
and then check what paperclip read that file – Officiaryapplication/*
. – IntendmentValidation failed: r_file has contents that are not what they are reported to be
– Intendment