Title: Unable to upload file to Genero server - com.HTTPServiceRequest Post by: Jan S. on August 26, 2014, 01:08:12 pm 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: Code
But in the Genero I'm still getting request part count = 0. Am I missing something? Thanks Jan Title: Re: Unable to upload file to Genero server - com.HTTPServiceRequest Post by: Frank G. on August 26, 2014, 04:19:12 pm Hi,
when you have only one part, it is considered as the main part and must be handled with the method req.readDataRequest(). Something like following : DEFINE b BYTE # Check multipart ... LOCATE b IN MEMORY CALL srv.readDataRequest(b) ... b.writeFile("myfile.jpg") And all other parts will then be available via the getRequestPart() and getRequestPartCount(). Frank. Title: Re: Unable to upload file to Genero server - com.HTTPServiceRequest Post by: Jan S. on August 26, 2014, 04:58:02 pm Thanks for your reply.
However, now for the same requests, program on method call req.readDataRequest(b) is throwing these exceptions: FORMS statement error number -15549. HTTP runtime exception : Unexpected end of multipart protocol. FORMS statement error number -15549. HTTP runtime exception : Mulitpart protocol error 1. Jan Title: Re: Unable to upload file to Genero server - com.HTTPServiceRequest Post by: Frank G. on August 26, 2014, 06:36:08 pm Hi,
I reproduced the issue and filed a new bug #GWS-442 : Reading a 'form-data' multipart response where first part contains a Content-Disposition header does not work. Sorry for the inconvenience Frank Title: Re: Unable to upload file to Genero server - com.HTTPServiceRequest Post by: Frank G. on August 27, 2014, 10:04:36 am Hi,
As workaround, you can add a main part of type text in your HTML formular (maybe as hidden), and send as second part the file. See attached sample. Hope it helps Frank Title: Re: Unable to upload file to Genero server - com.HTTPServiceRequest Post by: Jan S. on August 27, 2014, 01:58:19 pm Hi,
request posted from your html form is processed correctly. But when I'm posting similar request with "hack" part from my Android client I'm getting another error, still on calling req.readDataRequest(b): FORMS statement error number -15549. HTTP runtime exception : No valid header on HTTP request.. Headers seem to be OK, if I get them by the req.getRequestHeaderValue() method and display to console before reading data part. The request is attached. Jan Title: Re: Unable to upload file to Genero server - com.HTTPServiceRequest Post by: Frank G. on August 27, 2014, 03:20:25 pm I did not reproduce with the workaround.zip test case on Android. I'm a bit confused, you say that you get an error on readDataRequest(), but this method is not called in my workaround test case. Can you please clarify ?
Notice that I used Chrome as browser on Android, do you have another browser or a dedicated client app ? Thanks Title: Re: Unable to upload file to Genero server - com.HTTPServiceRequest Post by: Jan S. on September 01, 2014, 09:50:35 am Hi,
sorry for your confusion. I tried various modifications. In your workaround case program fails on readTextRequest() with the same error message "HTTP runtime exception : No valid header on HTTP request..". I'm sending request from my own native Android test app using Ion library (https://github.com/koush/ion (https://github.com/koush/ion)) for networking. my test upload method: Code
Jen Title: Re: Unable to upload file to Genero server - com.HTTPServiceRequest Post by: Frank G. on September 04, 2014, 05:48:14 pm Hi,
Sorry but I'm not able to reproduce. I did a dedicated android app using the Ion library and your code sample, but I'm still able to communicate with the FGL server. Could you maybe retry and set FGLWSDEBUG=3 before starting the fglrun server. Thanks, Frank Title: Re: Unable to upload file to Genero server - com.HTTPServiceRequest Post by: Jan S. on September 05, 2014, 09:16:29 am Hi,
I set FGLWSDEBUG=3 according to your advice. output: WS-DEBUG (Receive) POST /upload HTTP/1.1 WS-DEBUG END WS-DEBUG (Receive) Host: chsrv07.vera.local:8090 User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.4.2; sdk Build/KK) Accept-Encoding: gzip, deflate Accept: */* Connection: Keep-Alive Content-Type: multipart/form-data; boundary=----------------------------8ae7246c4b534bc8bbabd1440aa66de2 Content-Length: 26011 WS-DEBUG END http://chsrv07.vera.local:8090/upload method: POST type: form-data WS-DEBUG (Receive) ------------------------------8ae7246c4b534bc8bbabd1440aa66de2\r\nContent-Disposition: form-data; name="hack"\r\n\r\n WS-DEBUG END WS-DEBUG (Receive) \r\n WS-DEBUG END WS-DEBUG (Receive) ------------------------------8ae7246c4b534bc8bbabd1440aa66de2\r\nContent-Disposition: form-data; name="IMG_20140905_024752.jpg"; filename="IMG_20140905_024752.jpg"\r\n\r\n WS-DEBUG END WS-DEBUG (IO ERROR) Class: HTTPHeader::readMultipart() Msg: No valid header on HTTP request. Code: 0 WS-DEBUG END WS-DEBUG (HTTP ERROR) Class: HTTPMultipartParser Msg: No valid header on HTTP request. WS-DEBUG END Program stopped at 'MultipartServer.4gl', line number 45. FORMS statement error number -15549. HTTP runtime exception : No valid header on HTTP request.. Jan Title: Re: Unable to upload file to Genero server - com.HTTPServiceRequest Post by: Jan S. on September 05, 2014, 12:49:46 pm Hi,
until now I has been testing upload only with a program running in standalone mode. It's little strange that it works with various clients except Ion. Now I tried to deploy the MultipartServer program on the GAS. Through the GAS upload is working now even with a client using Ion library! Thanks for your support Frank. Jan |