Ruby Rails 3.2.8/Carrierwave-图像上传接收多部分不是正常形式
我有一个api,我需要从移动设备或其他设备接收图像文件,但服务器没有表单。我想根据mac_address变量检查哪个用户 该模型具有以下代码:Ruby Rails 3.2.8/Carrierwave-图像上传接收多部分不是正常形式,ruby,ruby-on-rails-3,file-upload,carrierwave,Ruby,Ruby On Rails 3,File Upload,Carrierwave,我有一个api,我需要从移动设备或其他设备接收图像文件,但服务器没有表单。我想根据mac_address变量检查哪个用户 该模型具有以下代码: class Image < ActiveRecord::Base attr_accessible :mac_address, :superclass_id, :user_id, :file_path, :file_size belongs_to :mac_address mount_uploader :file_path, Fil
class Image < ActiveRecord::Base
attr_accessible :mac_address, :superclass_id, :user_id, :file_path, :file_size
belongs_to :mac_address
mount_uploader :file_path, FileUploader
end
那么我应该在控制器中做什么来接收该文件呢?从rails创建表单很容易,但这种方式似乎不可能
如何继续?如果映像托管在远程服务器上,并且此服务器可从您尝试保存映像的位置获得。您可以试试这个。图像是通过手机发送的。因此,无法从服务器保存图像。显然,从URL保存图像是显而易见的。但是我需要接收文件并存储它。
class FileUploader < CarrierWave::Uploader::Base
storage :fog
include CarrierWave::MimeTypes
process :set_content_type
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
http://localhost:3000/api/v1/images/MAC_ADDRESS?filename=something.png