文件阅读来自亚马逊的服务器,Ruby on Rails的,没有匹配的路由 [英] File reading from Amazon server, ruby on rails, no match route
问题描述
我现在开发上轨,Heroku的服务器和AWS应用红宝石。 在应用方面,我要读的文本文件。我测试在本地,现在把这个文件在AWS。
当我把我的AWS文件的地址,下面的错误信息弹出。
变量Errno :: ENOENT(没有这样的文件或目录@ rb_sysopen - https://s3-us-west-2.amazonaws.com/ringleplus2015/my_file.txt):
当我复制粘贴此地址在Chrome浏览器,我可以下载的文件没有问题。
#FILE = File.open方法(./ my_file.txt适用,R)
文件= File.open方法(https://s3-us-west-2.amazonaws.com/testbuckethoho/my_file.txt,R)
我允许任何人阅读。
此外,在html.rb文件,我也把链接,用户将能够从PDF文件下载。 目标=_空白级=BTN BTN-LG BTN-默认>案例下载
但是,当我点击它,它说:此网页无法使用。我期待地址仔细和:走了的HTTPS和//
<$p$p><$c$c>https//s3-us-west-2.amazonaws.com/testbuckethoho/What+Consumers+Want+from+Their+Displays+%7C+The+Applied+Materials+Blog.pdf当我有:在那里,它的工作原理。但是,如果我有:在我的HTML文件,它使我这个错误
没有路由匹配[GET] "/home/:/https:/s3-us-west-2.amazonaws.com/testbuckethoho/What+Consumers+Want+from+Their+Displays+%7C+The+Applied+Materials+Blog.pdf"
会有人帮我找出现在是什么原因造成这个问题和处理呢? :)
红宝石寻找一个名为本地文件 https://s3-us-west-2.amazonaws.com/testbuckethoho/my_file .TXT
。它不知道做一个请求到远程主机。
有一个不同的方法来解决这个问题,内置的一个是开放式URI 。
I'm now developing Ruby on rails application with Heroku server and AWS. In the application, I have to read the text file. I tested locally and now put this file in AWS.
When I put the address of my file in AWS, the below error message pops up.
Errno::ENOENT (No such file or directory @ rb_sysopen - https://s3-us-west-2.amazonaws.com/ringleplus2015/my_file.txt):
When I copy and paste this address at Chrome, I can download file without an issue.
#file = File.open("./my_file.txt","r")
file = File.open("https://s3-us-west-2.amazonaws.com/testbuckethoho/my_file.txt","r")
I allowed anybody to read this.
Also, in the html.rb file, I also put the link that users would be able to download pdf file from. " target="_blank" class="btn btn-lg btn-default">Case Download
But when I clicked it, it says " This webpage is not available." I look the address carefully and the ":" is gone between "https" and "//"
https//s3-us-west-2.amazonaws.com/testbuckethoho/What+Consumers+Want+from+Their+Displays+%7C+The+Applied+Materials+Blog.pdf
When I include ":" there, it works. But if I include ":" in my html file, it leads me to this error.
No route matches [GET] "/home/:/https:/s3-us-west-2.amazonaws.com/testbuckethoho/What+Consumers+Want+from+Their+Displays+%7C+The+Applied+Materials+Blog.pdf"
Would anybody help me figure out what is now causing this problem and handle it? :)
Ruby is looking for a local file named https://s3-us-west-2.amazonaws.com/testbuckethoho/my_file.txt
. It doesn't know to make a request to a remote host.
There's a various approaches to solve this, the built-in one is open-uri.
这篇关于文件阅读来自亚马逊的服务器,Ruby on Rails的,没有匹配的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!