login about faq

Hello,

We are trying to send contents of a file to server using request parameter. For this, we used the following code:

httpRequest.put_HttpVerb("POST");
httpRequest.put_ContentType("multipart/form-data");
httpRequest.put_Path("Sample/" + servlet);
httpResponse = chilkatEngine.SynchronousRequest("http://192.168.1.51", 8443, false, httpRequest);
String paramFilePath = "full/path/for/file.txt";
boolean success = httpRequest.AddFileForUpload("paremeterName", paramFilePath);

From the server side, when we read the data, we are unable to read the input stream. We are able to get other parameters from headers. Just the stream is missing. Requests are sent with POST method.

Here is the log from client:

 ChilkatLog:
   SynchronousRequest:
     DllDate: Dec  5 2014
     ChilkatVersion: 9.5.0.46
     UnlockPrefix: *********
     Username: ******:******
     Architecture: Little Endian; 32-bit
     Language: Windows Java
     VerboseLogging: 0
     domain: http://192.168.1.55
     port: 8443
     ssl: 0
     httpRequest:
       httpVersion: 1.1
       verb: POST
       path: /Sample/SampleServlet
       contentType: multipart/form-data
       charset: windows-1252
       sendCharset: 0
       mimeHeader: SampleID: 1
SessionID: a62db668d42f54999c906931d4545b612d74c8392c282475-255510029
UserName: user1
       requestParams:
         requestItem:
           name: paremeterName
           fileOnDisk: "full/path/for/file.txt"
           numValueBytes: 43
         --requestItem
         requestItem:
           name: SessionID
           value: a62db668d42f54999c906931d4545b612d74c8392c282475-255510029
         --requestItem
         requestItem:
           name: SampleID
           value: 1
         --requestItem
       --requestParams
     --httpRequest
     readTimeout: 20
     connectTimeout: 10
     approxRequestSize: 363
     fullRequest:
       a_synchronousRequest:
         generateRequest:
           httpRequestGenStartLine:
             genStartLine:
               startLine: POST /Sample/SampleServlet HTTP/1.1
             --genStartLine
           --httpRequestGenStartLine
           addCookies:
             Not auto-adding cookies.
           --addCookies
           genMultipartFormData:
             requestParam:
               name: SampleServletParameters
               filename: 
full/path/for/file.txt
             --requestParam
             requestParam:
               name: SessionID
             --requestParam
             requestParam:
               name: SampleID
             --requestParam
           --genMultipartFormData
         --generateRequest
         fullHttpRequest:
           domain: 192.168.1.55
           port: 8443
           ssl: 0
           openHttpConnection:
             Opening connection directly to HTTP server.
             httpHostname: 192.168.1.55
             httpPort: 8443
             ssl: 0
             connectElapsedMs: 858
             HTTP connection succeeded.
           --openHttpConnection
           connectTime: Elapsed time: 858 millisec
           sendRequestHeader:
             sendHeaderElapsedMs: 0
           --sendRequestHeader
           sendRequestBody:
             genMultipartFormData:
               requestParam:
                 name: paremeterName
                 filename: full/path/for/file.txt
               --requestParam
               requestParam:
                 name: SessionID
               --requestParam
               requestParam:
                 name: SampleID
               --requestParam
             --genMultipartFormData
             sendBodyElapsedMs: 0
           --sendRequestBody
           statusCode: 200
           statusText: OK
           readResponseBody:
             Response is chunked.
           --readResponseBody
         --fullHttpRequest
         success: 1
       --a_synchronousRequest
       success: 1
     --fullRequest
     totalTime: Elapsed time: 11544 millisec
     Success.
   --SynchronousRequest
--ChilkatLog

ChilkatLog:
   PostUrlEncoded:
     DllDate: Dec  5 2014
     ChilkatVersion: 9.5.0.46
     UnlockPrefix: ********
     Username: *****:*****
     Architecture: Little Endian; 32-bit
     Language: Windows Java
     VerboseLogging: 0
     url: http://192.168.1.55:8443/Sample/SampleServlet
     httpRequest:
       httpVersion: 1.1
       verb: GET
       path: /Sample/SampleServlet
       contentType:
       charset: windows-1252
       sendCharset: 0
       mimeHeader: SessionID: 
a62db668d42f54999c906931d4545b612d74c8392c282475-255510029
SampleID: 1
       requestParams:
         requestItem:
           name: SessionID
           value: a62db668d42f54999c906931d4545b612d74c8392c282475-255510029
         --requestItem
         requestItem:
           name: SampleID
           value: 1
         --requestItem
       --requestParams
     --httpRequest
     fullRequest:
       a_synchronousRequest:
         generateRequest:
           httpRequestGenStartLine:
             genStartLine:
               startLine: POST /Sample/SampleServlet HTTP/1.1
             --genStartLine
           --httpRequestGenStartLine
           addCookies:
             Not auto-adding cookies.
           --addCookies
         --generateRequest
         fullHttpRequest:
           domain: 192.168.1.55
           port: 8443
           ssl: 0
           openHttpConnection:
             Using existing connection.
           --openHttpConnection
           connectTime: Elapsed time: 0 millisec
           sendRequestHeader:
             sendHeaderElapsedMs: 0
           --sendRequestHeader
           sendRequestBody:
             sendBodyElapsedMs: 0
           --sendRequestBody
           statusCode: 200
           statusText: OK
           readResponseBody:
             contentLength: 2173
           --readResponseBody
         --fullHttpRequest
         success: 1
       --a_synchronousRequest
       success: 1
     --fullRequest
     Success.
   --PostUrlEncoded
--ChilkatLog

I am sure, we are missing something. Appreciate your quick response.

Thanks,

asked Mar 31 '15 at 02:19

iOSDev's gravatar image

iOSDev
11


I haven't used this object myself, nor code in the language you're using (C#?), but your code looks like it's adding the file to the upload after making the request to the server. Shouldn't you be adding the file before calling sending the request to the server (line 4 of your sample code)?

Dan

link

answered Mar 31 '15 at 07:19

AgeofStrife's gravatar image

AgeofStrife
9614

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×3

Asked: Mar 31 '15 at 02:19

Seen: 706 times

Last updated: Mar 31 '15 at 07:19

powered by OSQA