Heroku 与 sinatra 没有 RAILS_ROOT 或 Rail.root

发布于 2024-12-28 03:41:43 字数 155 浏览 3 评论 0原文

我正在尝试将文件上传到亚马逊 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猥琐帝 2025-01-04 03:41:43

我假设您已经阅读了 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 to RAILS_ROOT.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文