Heroku 与 sinatra 没有 RAILS_ROOT 或 Rail.root
我正在尝试将文件上传到亚马逊 s3,显然我必须先写入临时文件,然后上传该文件。但我不知道如何使用 Sinatra 和 heroku 来做到这一点,因为它找不到“#{RAILS_ROOT}”或#{Rail.root} 如何使用 heroku 将临时文件上传到 sinatra。
谢谢
I'm trying to upload file to amazon s3 and apparently I have to write to a temp file first then upload that file. But I cannot figure it out how to do that with Sinatra and heroku since it cannot find "#{RAILS_ROOT}" or #{Rail.root} how do I upload temp file to sinatra with heroku.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您已经阅读了 Heroku 的上传到 S3 文档。 Heroku 上的临时目录路径是
./tmp
。如果您正在运行 Sinatra,Heroku 可能不会创建与 Rails 相关的环境变量(尽管可能会,我不确定)。 此处是有关 Heroku 文件系统的更多信息。编辑:在 Sinatra 中,您可以通过
settings.root
获取根目录,类似于RAILS_ROOT
。I'm assuming you have read through Heroku's docs for Uploading to S3. The temp directory path on Heroku is
./tmp
. If you are running Sinatra, Heroku likely does not create the environment variables related to Rails (although it may, I'm not sure). Here is more info on Heroku's file system.EDIT: In Sinatra, you can get the root directory via
settings.root
, similar toRAILS_ROOT
.