2012-10-11 2 views
0

xmlhttprequest를 통해 실행되는 에이전트를 작성하려고하고 유니 코드 및 Base64로 인코딩 된 이미지를 매개 변수로 사용하여 을 허용합니다. 내가 에이전트가 base64로 문자열을 디코딩하는 내가 다음으로 MimeEntity를 작성, 스트림에 인코딩 된 문자열을 base64로를 작성 시도한 서식있는 텍스트 필드에이전트의 서식있는 텍스트 항목에 인라인 이미지 만들기

에 인라인 이미지 로 쓰기 위해이야 무엇

자녀 엔티티와는 는 그 다음 MimeEntity 항목을 얻고 RichTextItem

. 
. 
. 
Call stream.Writetext(data) 
. 
Set body = doc.CreateMIMEEntity("RT") 


Set header = body.CreateHeader("Content-Type") 
Call header.SetHeaderVal("multipart/mixed") 
. 
Set child = body.CreateChildEntity() 
Call child.Setcontentfrombytes(stream, "image/jpeg", 1727) 
Call child.Decodecontent() 
. 
Call RT.AppendRTItem(MimeEntityItem) 

에 추가 스트림에서 콘텐츠를 설정하지만 나는 6400byte 이미지/jpeg 파일 으로 끝낼 그리고 지금은 어떤을하지 않습니다 추가

누구나이 작업을하는 방법에 대한 단서가 있습니까? 사전에 감사합니다 =)

편집 :

좋아, 난 그냥 유효한 base64로 문자열 을 가진 파일을 생성하지만


좋아 디코딩되지 않습니다 지금 난에있어 생각 적어도 여기까지 :

서식있는 텍스트 항목에 올바른 이미지를 추가
Option Public 
    Option Declare 

    Sub Initialize 

     Dim session As NotesSession 
     Dim doc As NotesDocument 
     Dim query_string As String 
     Dim params As Variant 
     Dim i As Integer 
     Dim db As NotesDatabase 
     Set session = New NotesSession 
     Set doc = session.DocumentContext 
     query_string = doc.QUERY_STRING(0) 

    On Error GoTo errorrt 
     params = Split (query_string,"&") 

     Print("<html><head></head><body>") 

     Print params(1); 
     Print("<br>") 
     Print ({<img src="data:image/png;base64,} & params(2) & {"></img>}) 
     Set db = session.Currentdatabase 
     Set doc = db.Getdocumentbyunid(params(1)) 
     If doc Is Nothing Then 
      Print ("Ne") 
     End If 
     Print (doc.Getitemvalue("tatkun")(0)) 
     Print ("</body></html>") 

     Call AttachSignature(doc,params(2),"signature") 

     Exit Sub 
    errorrt: 
     Print (Error & " " & erl) 
     Exit Sub 
    End Sub 


    Function AttachSignature(doc As NotesDocument, data As Variant, filename As String) As Boolean 

    AttachSignature = False 

    Dim session As New NotesSession 
    Dim db As NotesDatabase 
    Dim body As NotesMIMEEntity 
    Dim header As NotesMIMEHeader 
    Dim child As NotesMIMEEntity 
    Dim stream As NotesStream 
    Dim fileType As String 
    Dim rt1 As NotesRichTextItem 
    Dim rt2 As NotesRichTextItem 

    On Error GoTo ErrorRoutine 

    Set db = doc.Parentdatabase 
    Set stream = session.CreateStream 

    Call stream.Writetext(data) 'Write the Data to the Stream 


    If doc.Getitemvalue("SignatureAttached")(0) = "1" Then 
     Exit Function 
    End If 

    Set body = doc.CreateMIMEEntity("TempRT")  

    Set header = body.CreateHeader("Content-Type") 
    Call header.SetHeaderVal("multipart/mixed") 

    Call body.CreateHeader("Content-Disposition"). _ 
    SetheaderValAndParams({attachment; filename="} &filename & {"}) 


    Set child = body.CreateChildEntity() 

    fileType = "image/jpeg" 

     Call child.SetcontentfromText(stream, fileType, 1727) 
     Call stream.Close() 
     Call body.Decodecontent() 

    Call doc.save(False, False) 

    Set rt1 = doc.GetFirstItem("signature") 
    Set rt2 = doc.GetFirstItem("TempRT") 

    Call rt1.AppendRTItem(rt2) 
    Call rt2.Remove() 

    doc.SignatureAttached = "1" 

    Call doc.save(False, False) 

    AttachSignature = True 

    Exit Function 

    ErrorRoutine: 
    If Not rt2 Is Nothing Then 
     Call rt2.Remove() 
    End If 
    Print (Error & " " & Erl) 
    Exit Function 
    End Function 

=)

하지만 인라인 이미지를 만들 수있는 방법을 모르겠다. 그리고 파일 이름이 잘못되었습니다. 사용 후 헤더를 iamge를 저장하는 MIMEEntity에, 그리고 : 어떤 도움

다시 고맙습니다 =)

답변

0

내가 대신/다중 혼합의 관련/다중를 사용하고 콘텐츠-ID를 할당 싶은 생각 이미지의 콘텐츠 ID를 참조하십시오.

0

희망이 해결 될 수 있습니다.

Dim session As New NotesSession 
    Dim db As NotesDatabase 
    Dim doc As NotesDocument 
    'Dim acl As NotesACL 
    'Dim entry As NotesACLEntry 
    Dim richStyle As NotesRichTextStyle 
    Dim rtitem As NotesRichTextItem 
    Set db = session.CurrentDatabase 
    Set doc = db.CreateDocument 
    Dim s As New NotesSession 
    Dim stream As NotesStream 
    Dim body As NotesMIMEEntity 
    Dim child As NotesMimeEntity 
    Dim header As NotesMIMEHeader 
    Set body = doc.CreateMIMEEntity("RT") 


    topString = Split(BASE64, ",") 

    Dim tmp_array() As String 
    i = 0 

    For i = 0 To Ubound(topString) 
     Redim Preserve tmp_array(i) 
     tmp_array(i) = topString(i) 

     Set child = body.CreateChildEntity() 
     Set header = child.CreateHeader("Content-Type") 
     Call header.SetHeaderVal("multipart/mixed") 
     Set header =child.createHeader("Content-Disposition") 
     Call header.setHeaderVal({attachment; filename=test} &Cstr(i)& {.jpg}) 'file name and type should be config 


     Set header =child.CreateHeader("Content-ID") 
     Call header.SetHeaderVal("test" &Cstr(i)& ".jpg") 

     Set stream = s.CreateStream() 
     Call stream.WriteText(topString(i)) 
     Call child.SetContentFromText(stream, "", ENC_BASE64) 




    Next 

    doc.form="Attachment" 
    'doc.Attachment = tmp_array 
    Call doc.save(True,False) 
    Call stream.Close() 
    s.ConvertMIME = True ' Restore conversion 
관련 문제