无法从Rails将图像上传到Paperclip:#<paperclip :: errors :: notidentifiedbyimagemagickerror:

时间:2015-06-03 00:49:55

标签: java ruby-on-rails heroku imagemagick paperclip

=“”

首先,我正在运行Rails 4 Heroku的。

我正在使用Paperclip gem构建用于上传图像的API。

api端点使用参数图像&#39;用于上载文件的原始字节。

上传到Paperclip的代码如下所示:

contents = input['image']

file = Tempfile.new('foo')
file.write(contents)

attachment = {
    :filename => 'test',
    :type => 'test',
    :headers => 'image',
    :tempfile => file
}
image = ActionDispatch::Http::UploadedFile.new(attachment)

来自heroku日志的图像原始文件字节(由Android应用程序生成)如下所示:

2015-06-03T00:40:01.153210+00:00 app[web.1]: 8ijJz0r\nrorhZseXgk/fc8Aen1oKUW9jHlUSEl42Ow5XyzjA+ma56fTZg4uioAIBwHwT6cmu6lKoVDhGEvDs\nDgen8qrSQrLOImGYzH8iq2ARSdluapWPP5llSQl49pLAIQ3QV3ml3DrY+c7rNtGVSUYINV7jRw8g\naQD5RwqqcY+tZF2rQqiQzkbEIfDYBHp+NYvlexrBPdHqGk3S3sMgLF2YAlPugHHGK6mwhkldIlRl\nnVlYsxyWH1rybRbia0jimkWQBl6BuCfevR9K1b94ssWWleIBgozhuK4qy0OuCsj2nSIZ4dlvAfJR\nkLSFecmuitTAS8boPPhf5ZwMsSP5V5ppviGSCdDJKZI3G1WXsfcdq9T8OGOeC4vLlCs8pxGq/dK+\np9682W50K/UueILmf+zrRVf96MKQw6gjnj1rxnxt4f8A7V0cuzRwzRqWDhADgf5Fe0TzQ3NvJbuQ\n8iFgjE5yR3rzrX1N3YyWiybfMiK78dG9Kjm5WM8o+DMepx66sM7IITdIcjJGQeP0r9LNHWNFEr3C\nvK0QIiLcqPpX50eB7U2XjzStOl3k+aJdokKqwHGffvX33qcSWFvBeIfKQRJkqx3HI6VwY2pywuNO\nxsN4O8V/E3xF4e+GfgRZpvGHxC1yDTtD+y43K0jAsxyOAqBifpX+jd+x78A/C37MfwB8DfCrwt4c\nsPDqaZoltLrU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AAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

该字符串是由这行Java代码创建的:

String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);

任何人都知道这里发生了什么?

0 个答案:

没有答案