Ruby on rails Rails-从POST请求/八位字节流读取文件
我在一个POST请求中发送了一张照片,内容类型为:来自android应用程序的binary/octect stream,我不知道如何在服务器端读取它。当前代码返回500错误:Ruby on rails Rails-从POST请求/八位字节流读取文件,ruby-on-rails,http,Ruby On Rails,Http,我在一个POST请求中发送了一张照片,内容类型为:来自android应用程序的binary/octect stream,我不知道如何在服务器端读取它。当前代码返回500错误: def send_photo_attachment @tempfile = Tempfile.new @tempfile.binmode @tempfile.write request.body.read @tempfile.rewind uploaded_file = Act
def send_photo_attachment
@tempfile = Tempfile.new
@tempfile.binmode
@tempfile.write request.body.read
@tempfile.rewind
uploaded_file = ActionDispatch::Http::UploadedFile.new(
tempfile: @tempfile,
filename: "photo.jpg"
)
uploaded_file.content_type = "image/jpeg"
@message_content = MessageContent.new
@message_content.content = uploaded_file
@message_content.mimetype = "image/jpeg"
render :attachment_id
end
任何帮助都将不胜感激