从LotusScript Web代理将pdf文件流式传输到浏览器 [英] Streaming a pdf file to the browser from a LotusScript web agent

查看:182
本文介绍了从LotusScript Web代理将pdf文件流式传输到浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个LotusScript Web代理,该代理将读取网络上某处pdf文件的内容,并将其作为流返回给浏览器.

I'm creating a LotusScript web agent that reads the content of a pdf file somewhere on the network and returns it as a stream to the browser.

该代理将被称为:getPDF?openAgent&pdfId=123456,它应直接返回pdf流. (我尚未实现url参数捕获)

the agent will be called like this : getPDF?openAgent&pdfId=123456 and it should directly returns the pdf stream. (I didn't implement yet the url parameter catching)

这是我目前的尝试,我仍然遇到将读取缓冲区转换为最终流的问题

Here's my current try, I still have an issue to convert the read buffer to the final stream

Sub Initialize
    On Error GoTo errrorhandle
    Dim session As New NotesSession
    Dim stream As NotesStream
    Set stream = session.CreateStream
    Dim buffer As variant
    Dim fileNum As Integer
    Dim txt As String
    Dim filename As String
    Dim filecontent As String

    filename = "C:\temp\test.PDF"

    If Not stream.Open(filename,"binary") Then
        MessageBox filename,, "Open failed"
        Exit Sub
    End If

    If stream.Bytes = 0 Then
        MessageBox filename,, "File has no content"
        Exit Sub
    End If

    Print "content-type:application/pdf"
    Do
        buffer =  stream.read(1)
        Print buffer(0)
    Loop Until stream.IsEOS

    Call stream.Close

    Exit Sub
errrorhandle :
    Print "Error :" & Error & " at line : " & Erl
    Exit sub
End Sub

推荐答案

Thomas Adrian回应中,附上pdf放入数据库中的文档中,然后按所述提供链接是最佳解决方案.

Following on Thomas Adrian response, attaching the pdf into a document in a database and then serve the link as described is the best solution.

请记住,如果该数据库具有或需要限制访问权限,则此要求对用户进行身份验证.

Keep in mind that this will require the user to be authenticated, if said database has or needs restricted access.

如果网络用户不是经过身份验证的用户,则您至少需要授予读者访问托管数据库的ACL中的匿名"权限,才能使其正常工作...如果数据库具有其他身份,则并不总是建议目的.

If the web users are not authenticated users, you'll need to give at least reader access to "Anonymous" in the ACL of the hosting database for this to work... which is not always advisable if the database has other purposes.

但是,您可以为此目的创建专用数据库,并具有不受限制的ACL访问权限.

You can however create a dedicated database just for this purpose, with unrestricted ACL access.

这篇关于从LotusScript Web代理将pdf文件流式传输到浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆