【发布时间】:2019-10-16 15:24:33
【问题描述】:
[编辑] 我相信我遗漏了我原来的问题。对我来说,问题似乎在于将解码的 MIMEEntity 的内容传递给流,我想将其写入文件。无论我如何尝试,我都无法让 Lotus 脚本将二进制数据写入文件。如果有人有任何有用的意见/建议/等等,我将不胜感激!
[原创] 我有以下代码
Dim a As String
a = "TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" & _
"AAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1v" & _
...
...
Dim session As New NotesSession
Dim stream As NotesStream
Dim doc As NotesDocument
Dim body As NotesMimeEntity
Dim db As NotesDatabase
Set session = New NotesSession
'Create stream and display properties
Set stream = session.CreateStream
'check if the file exists
If Not stream.Open("C:\\Notes\\update.dll") Then
'if the file doesnot exist then create one and add a time stamp to it
Dim fileNum As Integer
fileNum% = Freefile()
Open "/ww414/notes/ebcdicfile.txt" For Output As fileNum%
Close fileNum%
'this should have created the file. see if it existis now
If Not stream.Open("C:\\Notes\\update.dll") Then
'if the file has not been created yet then let the user know of the error that blocks the operation
Messagebox("Log file Is inaccessible")
End If
End If
Dim b As NotesStream
Set b = session.CreateStream
Call b.WriteText(a)
'==========================================================
'update file with the b64 decoded content
Set db = session.CurrentDatabase
Set doc = db.CreateDocument
session.ConvertMime = False
Set body = doc.CreateMIMEEntity
Call body.SetContentFromText(b, "", ENC_BASE64)
Call body.DecodeContent
content = body.ContentAsText
Call stream.WriteText(content)
'close stream/file open in memory
Call stream.Close()
问题是,文件被创建了,但是当涉及到内容时,它只是在其中放入了几个字节(而不是 14kb 的实际文件数据)
我检查了一堆论坛和可能的解决方案,但似乎没有一个有效。 例如: https://www.nsftools.com/tips/Base64v14.lss
https://ghads.wordpress.com/2008/10/17/vbscript-readwrite-binary-encodedecode-base64/
【问题讨论】:
-
只是一个想法,如果您流式传输到具有不同扩展名的文件(例如 .jpg 或 .gif),它是否有效?假设是某些防病毒进程阻止您动态创建 .dll。
-
嗨!不幸的是:(我遍历了所有可能的文件格式,还尝试设置 mime 标头(因此它会将其识别为“application/octet-stream”等)但没有成功。另外,我试图复制这个人的内容做了stackoverflow.com/questions/45796962/…,但同样没有成功。
-
来自 ContentAsText 属性帮助“非文本数据按原样返回,这可能会在进一步处理时出现问题。例如,包含空字符的数据可能会在字符串操作期间在空字符处被截断”在我看来,你真的想要 .GetContentAsBytest() 方法。
-
我也试过了,但由于某些原因它不起作用。但是,我终于让它工作了!一会儿我会在下面写一个详细的答案。非常感谢你们!
标签: vb.net lotus-notes lotus-domino lotusscript lotus