问题描述
我正在寻找一种通过 POST 方法将我的文件发送到我的服务器的方法。但首先我想将我的文件转换为 base64,以便我可以轻松发送它们。只是,我在互联网上找不到任何解决方案来做到这一点。我什至不确定这样做是否是个好主意。
我尝试了几种方法,包括直接从附加文件转换或将它们保存在本地并检索它们,但没有任何效果。
这是我的代码:
pathname = "C:\temp"
Set db = Session.Currentdatabase
Set CurrentDocColl = db.Unprocesseddocuments
Set doc = CurrentDocColl.Getfirstdocument
While Not doc Is nothing
Set item = doc.GETFirsTITEM("Body")
If doc.HasEmbedded Then
ForAll attachment In item.Embeddedobjects
Call attachment.ExtractFile (pathname & "\" & attachment.Name)
Set stream = session.Createstream()
stream.Open pathname & "\" & attachment.Name,"binary"
'I want retrieve the file in base64 here
data = 'file in base64
Set http=session.CreateHTTPRequest()
http.preferstrings = True
http.Post(url,data)
End ForAll
End If
Set doc=CurrentDocColl.Getnextdocument(doc)
Wend
可以在我的代理中找到此代码,该代理负责检索当前电子邮件中的信息。
有谁知道如何做到这一点?或者用另一种方式做同样的事情?
解决方法
您可以在 Julian Robicaux 的旧 NSFTools 网站上找到一些在 LotusScript 中处理 base64 数据的有用函数:https://www.nsftools.com/tips/Base64v14.lss