Heroku上的Rails Active Storage预览“内部500错误”

时间:2018-08-20 03:35:43

标签: ruby-on-rails heroku rails-activestorage

昨天附加了1个文件时,它运行良好,然后我更改为多个文件,并且不再显示预览。

似乎我正确地完成了所有操作,甚至还脚手架了另一个文档。

<% @document.files.each do |file| %>

<p><%= link_to "View File", file, target: '_blank' %> |
  <%= link_to "Download", file, download: '' %> </p>

<% if file.previewable? %>

  <li>
    <%= image_tag file.preview(resize_to_limit: [200, 200]) %>
  </li>

<% end %>
  

It is shown like this now

Preview images are shown with 500 error

也许它与Heroku构建包有关,是在昨晚还是在AWS上运行了?

Heruku日志:


2018-08-20T15:47:27.158676 + 00:00 app [web.1]:D,[2018-08-20T15:47:27.158541#4]调试-:[1m [36mActiveStorage :: Blob Load (5.4ms)[0m [1m [34mSELECT“ active_storage_blobs”。*从“ active_storage_blobs”,其中“ active_storage_blobs”。“ id” = $ 1 LIMIT $ 2 [0m [[“ id”,69],[“ LIMIT”,1]] 2018-08-20T15:47:27.121163 + 00:00的Heroku [路由器]:在= INFO方法= GET路径=“/导轨/ active_storage /申述/ eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBSdz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19 - dfa8c38d16bcbc65de1a2107a086925141bf585e / eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9VY21WemFYcGxYM1J2WDJ4cGJXbDBXd2RwQWNocEFjZz0iLCJleHAiOm51bGwsInB1ciI6InZhcmlhdGlvbiJ9fQ == - 7c2a4bf0af133050ffc289b97401f795dffdfdbc / EIN%20FunderHunt% 20(1).pdf“ host = desolate-temple-16025.herokuapp.com request_id = 7281973b-884b-455b-83a7-5a85910e790f fwd =” 71.190.148.218“ dyno = web.1 connect = 1ms service = 2689ms status = 500字节= 1891协议= https 2018-08-20T15:47:27.160499 + 00:00 app [web.1]:我,[2018-08-20T15:47:27.160404#4] INFO-:[ActiveJob] [ActiveStorage :: AnalyzeJob] [d7e86d99 -8801-4bdb-b63a-e1ba4946afad]从Async(默认)执行ActiveStorage :: AnalyzeJob(工作ID:d7e86d99-8801-4bdb-b63a-e1ba4946afad),参数为:#> 2018-08-20T15:47:27.274034 + 00:00 app [web.1]:I,[2018-08-20T15:47:27.273887#4] INFO-:[ActiveJob] [ActiveStorage :: AnalyzeJob] [d7e86d99 -8801-4bdb-b63a-e1ba4946afad] [36m S3存储(111.8ms)[0m [34m]从密钥下载的文件:wX8vV9RFa3J1bj5Lkynohj14 [0m 2018-08-20T15:47:27.415290 + 00:00 app [web.1]:D,[2018-08-20T15:47:27.414877#4]调试-:[ActiveJob] [ActiveStorage :: AnalyzeJob] [d7e86d99 -8801-4bdb-b63a-e1ba4946afad] [1m [35m(11.8ms)[0m [1m [35mBEGIN [0m 2018-08-20T15:47:27.423905 + 00:00 app [web.1]:D,[2018-08-20T15:47:27.423324#4]调试-:[ActiveJob] [ActiveStorage :: AnalyzeJob] [d7e86d99 -8801-4bdb-b63a-e1ba4946afad] [1m [36mActiveStorage :: Blob更新(3.2ms)[0m [1m [33mUPDATE“ active_storage_blobs” SET“元数据” = $ 1,其中“ active_storage_blobs”。“ id” = $ 2 [0m [[ “元数据”,“ {\” identified \“:true,\” width \“:612,\” height \“:792,\” analyzed \“:true}”],[“ id”,69]] 2018-08-20T15:47:27.433985 + 00:00 app [web.1]:D,[2018-08-20T15:47:27.433860#4]调试-:[ActiveJob] [ActiveStorage :: AnalyzeJob] [d7e86d99 -8801-4bdb-b63a-e1ba4946afad] [1m [35m(3.6ms)[0m [1m [35mCOMMIT [0m

2018-08-20T15:47:27.436119 + 00:00 app [web.1]:I,[2018-08-20T15:47:27.435928#4] INFO-:[ActiveJob] [ActiveStorage :: AnalyzeJob ] [d7e86d99-8801-4bdb-b63a-e1ba4946afad]在275.23ms内从Async(默认)执行了ActiveStorage :: AnalyzeJob(工作ID:d7e86d99-8801-4bdb-b63a-e1ba4946afad)

1 个答案:

答案 0 :(得分:1)

Heroku使用临时文件系统,这意味着一旦dyno停止或重新启动,存储在应用程序文件系统中的任何临时或上载文件将不可用。

每次部署应用程序时,Heroku都会重新启动测功机。表示所有上传的文件均被销毁。您应该尝试将文件上传到ActiveStorage支持的AWS S3之类的服务。

这是Heroku的文档。 Documentation Link

这里也是help.heroku.com Why are my file uploads missing/deleted?

上一个问题的链接。