B4J Question How do I get the content of multipart/form-data?

hzq200409

Member
Licensed User
For the following requests in jServer, is there a quick way to get them? For example, user_name.
B4X:
--------------------------00077618139f9eb3
Content-Disposition: form-data; name="channel_num"

1
--------------------------00077618139f9eb3
Content-Disposition: form-data; name="ipaddr"

10.2.50.5
--------------------------00077618139f9eb3
Content-Disposition: form-data; name="port"

8000
--------------------------00077618139f9eb3
Content-Disposition: form-data; name="user_name"

temp
--------------------------00077618139f9eb3--
 

peacemaker

Expert
Licensed User
Longtime User
Maybe back-coding of this ?
 
Upvote 0

hzq200409

Member
Licensed User
Maybe back-coding of this ?
Thank you for your attention. This post is about uploading. As an aside: and this upload example is not suitable for all situations, I have modified this code in a similar use environment.
 
Upvote 0

hzq200409

Member
Licensed User
Sorry, my English is not good enough. You may have misunderstood my meaning. I am writing the jServer program and I want to extract them in the service program.
 
Upvote 0

hzq200409

Member
Licensed User
Gets the 'name' of the multipart/form-data request.:
    If req.Method = "POST" Then
        If req.ContentType.Contains("multipart/form-data") Then
            Dim partData As Map = req.GetMultipartData(File.DirApp & "/tempUpload",2048000)
            If partData.IsInitialized Then
                For Each k As String In partData.Keys
                    Dim p As Part = partData.Get(k)
                    Dim Value As String = p.GetValue("utf8")
                    Log(k & ":" & Value)
                Next
            End If
        End If
    End If
B4X:
Dim content As TextReader
content.Initialize(req.InputStream) <----Wrong usage. Because the existence of this code makes the above code invalid. I fell into this trap.Because this code comes before the code above.
 
Last edited:
Upvote 0
Top