Hi,
I am trying to upload a file from Android client to Genero server using HTTP.
The multipart content of the HTTP request contains the only one single part with jpg image. There is no other body or file part.
My HTTP POST request looks like:
POST
http://172.16.6.27:8090/upload HTTP/1.1
Host: 172.16.6.142:8888
User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.0.4; sdk Build/MR1)
Accept-Encoding: gzip, deflate
Connection: keep-alive
Accept: */*
Content-Type: multipart/form-data; boundary=----------------------------2a708b2baf25414eb7f47c63975a07b2
Content-Length: 22141
------------------------------2a708b2baf25414eb7f47c63975a07b2
Content-Disposition: form-data; name="IMG_20140529_103509.jpg"; filename="IMG_20140529_103509.jpg"
... data ...
------------------------------2a708b2baf25414eb7f47c63975a07b2--
Server 4gl code:
IMPORT com
IMPORT xml
MAIN
DEFINE req com.HTTPServiceRequest
DEFINE url STRING
DEFINE method STRING
DEFINE doc xml.DomDocument
DEFINE type STRING
DEFINE ind INTEGER
DEFINE p com.HTTPPart
DEFINE resp STRING
DEFINE i INTEGER
DISPLAY "START"
CALL com.WebServiceEngine.Start()
LET req = com.WebServiceEngine.getHTTPServiceRequest(-1)
LET url = req.getURL()
DISPLAY url
IF url IS NULL THEN
DISPLAY "Failed: url should not be null"
EXIT PROGRAM (-1)
END IF
LET method = req.getMethod()
DISPLAY "method: ", method
IF method IS NULL OR method != "POST" THEN
DISPLAY "Failed: method should be POST"
END IF
# Check multipart type
LET type = req.getRequestMultipartType()
DISPLAY "type: ", type
IF type IS NULL THEN
DISPLAY "Failed: expected multipart in request"
END IF
# Process additional parts
LET resp = "count: ", req.getRequestPartCount()
DISPLAY resp
FOR ind = 1 TO req.getRequestPartCount()
LET p = req.getRequestPart(ind)
IF p.getAttachment() IS NOT NULL THEN
LET resp = resp, " att: ", p.getAttachment()
DISPLAY "Attached file at :",p.getAttachment()
ELSE
LET resp = resp, " content: ", p.getContentAsString()
DISPLAY "Attached part is :",p.getContentAsString()
END IF
END FOR
CALL req.sendTextResponse(200, "", resp)
END MAIN
But in the Genero I'm still getting request part count = 0.
Am I missing something?
Thanks
Jan