【问题标题】:Unable to get at attachment from url无法从 url 获取附件
【发布时间】:2019-05-13 13:52:53
【问题描述】:

我需要使用 url 获取存储在 Lotus Notes 文档中的附件。

我可以获取文档,好的,但是当我尝试使用 url 获取附件时,我得到一个 404 Attachment not found。

尝试使用 Domino 数据服务指南中的示例

http://infolib.lotus.com/resources/domino/8.5.3/doc/designer_up1/en_us/DominoDataService.html

获取文档的url是

https://mym.dev-imaginovation.net/Applications/Correspondence/corr2017.nsf/api/data/documents/unid/FB1620DDCA1D8C538025836000401312

这会生成 json,从这里我可以看到附件名称(如下所示)

  "boundary":"--0__=8FBB096ADFDA03268f9e8a93df938690918c8FBB096ADFDA0326"
          },
                    {
            "contentType":"application\/octet-stream; name=\"081409362-E_Notif_GoThrough_Regist.PDF\"",
            "contentID":"<2__=8FBB096ADFDA03268f9e8a93df93869091@local>",
            "contentDisposition":"attachment; filename=\"081409362-E_Notif_GoThrough_Regist.PDF\"",
            "contentTransferEncoding":"base64",
            "data":"JVBERi0xLjQKJeLjz9MKMSAwIG9iaiA8PC9EZWNvZGVQYXJtczw8L0sgLTEvQ29sdW1ucyAyN

当我尝试网址时

https://mym.dev-imaginovation.net/Applications/Correspondence/corr2017.nsf/api/data/documents/unid/FB1620DDCA1D8C538025836000401312/$File/081409362-E_Notif_GoThrough_Regist.PDF

我得到一个网页

{ “代码”:404, “文本”:“未找到”, “消息”:“未找到附件” }

有什么想法吗?

(链接不起作用,因为无法从 www 访问开发站点)

谢谢

格雷姆

【问题讨论】:

    标签: json lotus-domino


    【解决方案1】:

    数据已经在 GET 文档请求的响应中:

    {
        "contentType":"application\/octet-stream; name=\"081409362-E_Notif_GoThrough_Regist.PDF\"",
        "contentID":"<2__=8FBB096ADFDA03268f9e8a93df93869091@local>",
        "contentDisposition":"attachment; filename=\"081409362-E_Notif_GoThrough_Regist.PDF\"",
        "contentTransferEncoding":"base64",
        "data":"JVBERi0xLjQKJeLjz9MKMSAwIG9iaiA8PC9EZWNvZGVQYXJtczw8L0sgLTEvQ29sdW1ucyAyN ..."
    }
    

    data 属性包含附件的 base64 编码内容。 contentTransferEncoding 属性告诉您它是如何编码的。

    根据您使用的 Domino 版本,您还可以更改 GET 文档请求以获取附件链接而不是附件内容。只需将 ?attachmentlinks=true 添加到请求 URL 的末尾即可。这将导致响应具有 contentLocation 属性——其值是附件数据的相对 URL。

    重要提示:在 Domino 9.0.1 FP9 中添加了 attachmentlinks 参数。如果您使用的是旧版本的 Domino,?attachmentlinks=true 将被忽略。

    【讨论】:

      【解决方案2】:

      '$file' URL 路径不是 'api/data' 路径,但您可以使用 unid 和文件名来构建替代路径(假设您只希望在任何 Domino 服务器上以老式方式添加附件) :

      https://mym.dev-imaginovation.net/Applications/Correspondence/corr2017.nsf/0/FB1620DDCA1D8C538025836000401312/$File/081409362-E_Notif_GoThrough_Regist.PDF

      或更笼统地说:

      domain/app-path/db.nsf/view/key/$file/filename
      domain/app-path/db.nsf/view/unid/$file/filename
      

      或者使用 '0' 作为视图名占位符:

      domain/app-path/db.nsf/0/unid/$file/filename

      【讨论】:

        猜你喜欢
        • 2015-02-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-11
        • 2019-04-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多