Chris Guanzon Active Member Licensed User Longtime User Oct 23, 2022 #1 Hello, everyone! Please help me. How can I handle a postmultipart in JServer? I have a client using httpjob postmultipart. Code: Libraries.httpJob.PostMultipart(Variables.URL & path, CreateMap("key1": "values1", "key2": "values2"), Null) I tried using getMultipartData and this is what I got. Code: (MyMap) {key1=Part{n=key1,fn=null,ct=null,s=7,tmp=true,file=null}, key2=Part{n=key2,fn=null,ct=null,s=7,tmp=true,file=null}} This is the code I used on my server. Code: Sub Handle(req As ServletRequest, resp As ServletResponse) resp.ContentType = "application/json" Dim reqMap, respMap As Map reqMap.Initialize respMap.Initialize reqMap = req.GetMultipartData(File.Combine(File.DirApp, "www"), 100000000) Log(reqMap) end sub
Hello, everyone! Please help me. How can I handle a postmultipart in JServer? I have a client using httpjob postmultipart. Code: Libraries.httpJob.PostMultipart(Variables.URL & path, CreateMap("key1": "values1", "key2": "values2"), Null) I tried using getMultipartData and this is what I got. Code: (MyMap) {key1=Part{n=key1,fn=null,ct=null,s=7,tmp=true,file=null}, key2=Part{n=key2,fn=null,ct=null,s=7,tmp=true,file=null}} This is the code I used on my server. Code: Sub Handle(req As ServletRequest, resp As ServletResponse) resp.ContentType = "application/json" Dim reqMap, respMap As Map reqMap.Initialize respMap.Initialize reqMap = req.GetMultipartData(File.Combine(File.DirApp, "www"), 100000000) Log(reqMap) end sub
Erel B4X founder Staff member Licensed User Longtime User Oct 23, 2022 #2 Check "code smell #1": https://www.b4x.com/android/forum/t...ommon-mistakes-and-other-tips.116651/#content Code: For Each Key As String In reqMap.Keys Dim p As Part = reqMap.Get(Key) Dim Value As String = p.GetValue("utf8") Log(Key & ": " & Value) Upvote 0
Check "code smell #1": https://www.b4x.com/android/forum/t...ommon-mistakes-and-other-tips.116651/#content Code: For Each Key As String In reqMap.Keys Dim p As Part = reqMap.Get(Key) Dim Value As String = p.GetValue("utf8") Log(Key & ": " & Value)
Chris Guanzon Active Member Licensed User Longtime User Oct 23, 2022 #3 Thank you very much, Sir Erel! Code: Sub Handle(req As ServletRequest, resp As ServletResponse) resp.ContentType = "multipart/form-data" Dim reqMap As Map = req.GetMultipartData(File.Combine(File.DirApp, "www"), 1000000) For Each Key As String In reqMap.Keys Dim p As Part = reqMap.Get(Key) Dim Value As String = p.GetValue("utf8") Log(Key & ": " & Value) Next end sub Upvote 0
Thank you very much, Sir Erel! Code: Sub Handle(req As ServletRequest, resp As ServletResponse) resp.ContentType = "multipart/form-data" Dim reqMap As Map = req.GetMultipartData(File.Combine(File.DirApp, "www"), 1000000) For Each Key As String In reqMap.Keys Dim p As Part = reqMap.Get(Key) Dim Value As String = p.GetValue("utf8") Log(Key & ": " & Value) Next end sub