Android Question HttpJob.PostMultipart

bridge1

Member
Would there be a possibility that in the MultipartFileData class it is possible to accept a stream of bytes instead of a file?

Thanks.
 

DonManfred

Expert
Licensed User
Longtime User
What are you trying to archieve?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Interesting, but how to obtain the post from web server jetty version 7?

Use Request.InputStream with POST method where Request is ServletRequest

B4X:
Public Sub PostStreamBytes As HttpResponseMessage
    Try
        Dim tmp As String = File.Combine(Main.srvr.StaticFilesFolder, "tmp")
        Dim ins As InputStream = Request.InputStream
        Dim out As OutputStream = File.OpenOutput(tmp, "upload.pdf", False)
        File.Copy2(ins, out)
        out.Close
        HRM.ResponseCode = 200
    Catch
        Log(LastException)
        HRM.ResponseCode = 400
        HRM.ResponseError = "Error Input Stream"
    End Try
    Return HRM
End Sub
 
Last edited:
Upvote 0

bridge1

Member
I am not sure about Jetty 7.

As far as I know, we only have the following libraries:
jServer2 and jServer3 based on Jetty 9
and
jServer4 based on Jetty 11

Thank you very much. But unfortunately in the "B4a Http Server 1.0" library the jetty 7 webserver is used, which does not support the ServletRequest.InputStream method

What alternatives would you propose to receive the data in post?

We currently retrieve the name of the file that was sent and then retrieve it from the web server's temporary files.

B4X:
Dim sNameFileUploated As String = Request.GetUploadedFile(<key_name_fields_uploaded>)
        
'open the temporary file.
Dim oInputStream As InputStream
oInputStream = File.OpenInput(serverHTTP.TempFolder, sNameFileUploated)
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Oh, you are referring to B4A HttpServer created in 2013

HttpServer was built before B4J was available and especially before jServer was available. Real servers should be built with jServer.
I don't recommend using HttpServer.

This is a mistake to use HttpServer to build a client / server solution. There are much better options such as MQTT.

If you insist, I think this library supports
B4X:
GetInputStream As InputStream
 
Upvote 0

bridge1

Member
Oh, you are referring to B4A HttpServer created in 2013





If you insist, I think this library supports
B4X:
GetInputStream As InputStream

Thansk
Oh, you are referring to B4A HttpServer created in 2013





If you insist, I think this library supports
B4X:
GetInputStream As InputStream


Many thanks, but the library you reported is NOT the same it is "aHttpServer" we use "HttpServer"

Exposes the following methods for the "ServletRequest" class

Java:
//Returns the HTTP method (GET or POST).
public String getMethod()

// Returns the request URL without the host and any parameters.
public String getRequestURI()

// Returns the client IP address.
public String getRemoteAddress()

// Returns the parameter value or an empty string if the parameter does not exist.
public String GetParameter(String Name)

// Returns the name of the temporary file that was uploaded to Server.TempFolder.
public String GetUploadedFile(String Key)

Is the compatibility of the "HttpServer" library with the new "jServer" libraries supported, in your opinion?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Is the compatibility of the "HttpServer" library with the new "jServer" libraries supported, in your opinion?
Sorry, I couldn't answer your question as I am not familiar with both libraries.
Try to ask @Erel and @Star-Dust

Please start a new thread and explain more details.
I am confused since your initial question seems was about client's side httpjob in the title but you are asking about server's side httpserver class which is a different topic.
 
Upvote 0
Top