上传后某个时候在 Strapi 中访问媒体时出现 404 错误
404 Error with accessing media in Strapi sometime after uploading
一些上下文:
我已使用 MongoDB 后端在 Heroku 上成功部署了 Strapi,并且可以 add/edit 条目。当我使用媒体库插件上传图像时,我的问题就来了。我能够上传图像,并让我的前端最初访问它,在某个时间后显示它等,比如第二天或一个小时左右,文件的历史存在,可以通过这个端点看到:
https://blog-back-end-green.herokuapp.com/upload/files/
但是,用于访问媒体的 url 端点无法像以前那样工作,当我按照它到达端点时出现 404 错误。例如
https://blog-back-end-green.herokuapp.com/uploads/avatarperson_32889bfac5.png
Strapi 的新手所以任何 help/guidance 赞赏
当您的应用运行时,它会消耗 HEROKU 的测功小时数
当您的应用闲置时(自动,闲置 30 分钟后),只要您有 dyno 时间,您的应用就会上线并可公开访问。
通常,身份验证失败 return 401(未授权)错误但在某些平台上,404 错误也可能 return。
检查你的第二个请求确实有正确的授权header
docs直接解决你的问题:
Like with project updates on Heroku, the file system doesn't support
local uploading of files as they will be wiped when Heroku "Cycles"
the dyno. This type of file system is called ephemeral, which means
the file system only lasts until the dyno is restarted (with Heroku
this happens any time you redeploy or during their regular restart
which can happen every few hours or every day).
Due to Heroku's filesystem you will need to use an upload provider
such as AWS S3, Cloudinary, or Rackspace. You can view the
documentation for installing providers here and you can see a list of
providers from both Strapi and the community on npmjs.com.
一些上下文:
我已使用 MongoDB 后端在 Heroku 上成功部署了 Strapi,并且可以 add/edit 条目。当我使用媒体库插件上传图像时,我的问题就来了。我能够上传图像,并让我的前端最初访问它,在某个时间后显示它等,比如第二天或一个小时左右,文件的历史存在,可以通过这个端点看到:
https://blog-back-end-green.herokuapp.com/upload/files/
但是,用于访问媒体的 url 端点无法像以前那样工作,当我按照它到达端点时出现 404 错误。例如
https://blog-back-end-green.herokuapp.com/uploads/avatarperson_32889bfac5.png
Strapi 的新手所以任何 help/guidance 赞赏
当您的应用运行时,它会消耗 HEROKU 的测功小时数
当您的应用闲置时(自动,闲置 30 分钟后),只要您有 dyno 时间,您的应用就会上线并可公开访问。
通常,身份验证失败 return 401(未授权)错误但在某些平台上,404 错误也可能 return。
检查你的第二个请求确实有正确的授权header
docs直接解决你的问题:
Like with project updates on Heroku, the file system doesn't support local uploading of files as they will be wiped when Heroku "Cycles" the dyno. This type of file system is called ephemeral, which means the file system only lasts until the dyno is restarted (with Heroku this happens any time you redeploy or during their regular restart which can happen every few hours or every day).
Due to Heroku's filesystem you will need to use an upload provider such as AWS S3, Cloudinary, or Rackspace. You can view the documentation for installing providers here and you can see a list of providers from both Strapi and the community on npmjs.com.