【问题标题】:s3 no such key, The specified key does not exist. previewing document from urls3 no such key, 指定的key不存在。从 url 预览文档
【发布时间】:2017-05-23 23:30:35
【问题描述】:

我正在使用回形针,s3。我已经上传了一个 word 文档,现在我希望能够从数据库中预览它。我正在使用 iframe。

<iframe src="<%= agreement.document.url(:small) %>" frameborder="0" width="400" height="400" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"> </iframe>

总之我得到这个错误。如何预览word文档或pdf??

更新: 我有要显示的 pdf,但是不想显示 word 文档。 word文档显示为pdf显示的空白,而word文档询问我是否要下载文件。

因此,它要求我下载它,而不是显示 word 文档。

这是我改变的:

<iframe src="<%= agreement.document.url() %>" frameborder="0" width="400" height="400" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"> </iframe>

那么现在我该如何让word文档工作呢?这是一个文档

【问题讨论】:

    标签: html ruby-on-rails amazon-web-services iframe amazon-s3


    【解决方案1】:

    存储桶名称不正确,或者存储桶上不存在文件。

    如果您希望每个人都可以访问该文件,请确保该文件的权限是公开的。

    【讨论】:

    • 当我只使用agreement.document 或agreement.document.url 作为src 时,它要求我下载文件,这意味着我有权限并且它指向正确的文件。 iv 尝试包含我的域名www.domain.com/<%= agreement.document.url(:small) %>,但我得到了一个关于如何 |get| 的不同错误。路径不存在。
    • 您能否通过硬编码链接来检查您是否可以查看文档?如果它有效,那么您的代码有问题,而不是 s3。
    • 我更新了我的问题,因为我得到了 pdf 文件但不是 word 文件 ^^
    • 我认为并不是所有的浏览器都能够开箱即用地预览 Word 文档。您应该使用 pdf 显示预览并提供 word doc 的下载链接。
    猜你喜欢
    • 1970-01-01
    • 2018-05-29
    • 2021-05-12
    • 2017-08-23
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 2012-01-10
    • 2014-09-01
    相关资源
    最近更新 更多