You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by ke...@sz.murata.com.cn on 2010/06/09 05:22:58 UTC

How to post file by pivot.

Hi All,

Is there any example for post file and parameter to web server by pivot.
I check the pivot API doc,but seems pivot 1.5 can't do that.
Does we need use our custom API do it like (Apache httpclient)?
Please advise.

Best regards,
Ken Jiang

*******************************************
Murata Electronics Trading  (Shenzhen) Co.,Ltd
Tel:86-755-82847251
E-mail:kenjiang@sz.murata.com.cn
*******************************************


Re: How to post file by pivot.

Posted by Greg Brown <gk...@mac.com>.
The HTTP specification says that "if a resource has been created on the origin server, the response SHOULD be 201 (Created) and contain an entity which describes the status of the request and refers to the new resource, and a Location header":

  http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5

However, it is also valid to return HTTP 200 (OK) or HTTP 204 (No Content) if "the action performed by the POST method might not result in a resource that can be identified by a URI". 

If the server code that handles the upload is actually creating a resource, it should probably return HTTP 201 along with a Location header. However, if you don't have control over this code or can't change it for some reason, it may still be OK. Do you actually need the Location header? If not, you can probably just ignore the null return value. Alternatively, maybe the server returns some other header information you can use.


On Jun 11, 2010, at 5:05 AM, kenjiang@sz.murata.com.cn wrote:

> Hi Alejandro,
> Thank you in advance.
> I get the hint for my problems.
> Below is simple code.
> 
> But after I execute,the location is null.
> PostQuery postQuery1 = new PostQuery("localhost", 8080,
> "/pivot-tutorials/fileupload.jsp",false);
>            postQuery1.setValue("A");
>            URL location = postQuery1.execute();
> 
> Actually,I can use access this url.
> 
> (Embedded image moved to file: pic06334.gif)
> I use the debuger and I found getStatus is Status.OK(200) and not equal
> Status.CREATED(201).
> |--------------------------------------------------------------------------|
> | PostQuery.java,                                                          |
> |                                                                          |
> |   public URL execute() throws QueryException {                           |
> |        URL valueLocation = null;                                         |
> |                                                                          |
> |        execute(METHOD, value);                                           |
> |                                                                          |
> |        if (getStatus() == Status.CREATED) {                              |
> |--------------------------------------------------------------------------|
> 
> 
> Best regards,
> Ken Jiang
> 
> *******************************************
> Murata Electronics Trading  (Shenzhen) Co.,Ltd
> Tel:86-755-82847251
> E-mail:kenjiang@sz.murata.com.cn
> *******************************************
> 
> 
> 
>  From:       Greg Brown <gk...@mac.com>                                                                           
> 
>  To:         user@pivot.apache.org                                                                                  
> 
>  Date:       06/11/2010 11:51                                                                                       
> 
>  Subject:    Re: How to post file by pivot.                                                                         
> 
> 
> 
> 
> 
> 
> Great example, Alejandro.
> 
> Ken, note that pivot-web-1.5.jar, which contains everything you need to
> execute web queries, is 33k in size. HttpClient requires the following
> libraries, totaling 593k:
> 
> httpclient-4.0.1.jar
> httpcore-4.0.1.jar
> commons-logging-1.1.1.jar
> commons-codec-1.4.jar
> 
> pivot-web-1.5.jar does require pivot-core-1.5.jar (229k), but WTK already
> requires this library, so the net addition to include web query support in
> a Pivot app is 33k.
> 
> G
> 
> 
> On Jun 10, 2010, at 10:50 PM, Alejandro Vilar wrote:
> 
>> Hi Ken, as Greg mentioned in Pivot 1.5 there is a new class for files
>> manipulation related to web queries (FileSerializer).
>> 
>> You can try something like this on client side:
>> 
>> import java.io.File;
>> import java.net.URL;
>> import org.apache.pivot.io.FileSerializer;
>> import org.apache.pivot.web.*;
>> 
>> //...
>> String hostname = "fileserver.com";
>> try {
>>   //post
>>   File fileToSend = new File("sample.jpg");
>>   PostQuery postQuery = new PostQuery(hostname, "/files");
>>   postQuery.getParameters().put("filename", fileToSend.getName());
>>   postQuery.setSerializer(new FileSerializer());
>>   postQuery.setValue(fileToSend);
>>   URL url = postQuery.execute();
>> 
>>   //get
>>   GetQuery getQuery = new GetQuery(hostname, url.getPath());
>>   getQuery.setSerializer(new FileSerializer());
>>   File receivedFile = (File) getQuery.execute();
>> 
>> } catch (QueryException e) {
>>   e.printStackTrace();
>> }
>> //...
>> Hope this helps,
>> Alejandro
>> 
>> -----Original Message-----
>> From: kenjiang@sz.murata.com.cn [mailto:kenjiang@sz.murata.com.cn]
>> Sent: Jueves, 10 de Junio de 2010 10:14 p.m.
>> To: user@pivot.apache.org
>> Subject: Re: How to post file by pivot.
>> 
>> Hi Greg,
>> 
>> Thank you for your information.
>> For post parameter is ok.But I would like to post arbitrary file like
> some
>> JPG,GIF to existing web server.
>> For Example,
>> 1.User select the files.
>> 2.Post to server side JSP.
>> 3.Save files in server side.
>> 
>> In normal web application,we easily to do that.
>> I also use HTTPCLIENT to similar this action.It's Ok.
>> but is there simple way to use pivot function do that?I wouldn't like
>> include many third party lib in clinet JAR.
>> Since they may effect the loading applet time.
>> 
>> 
>> 
>> Best regards,
>> Ken Jiang
>> 
>> *******************************************
>> Murata Electronics Trading  (Shenzhen) Co.,Ltd
>> Tel:86-755-82847251
>> E-mail:kenjiang@sz.murata.com.cn
>> *******************************************
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>   Re: How to post file by pivot.
>> 
>> 
>> 
>> 
>> 
>>   Greg Brown
>> 
>>               to:
>> 
>>                 user
>> 
>> 
> 06/
>> 
>> 
> 09/
>> 
>> 
> 201
>> 
>> 
> 0
>> 
>> 
> 20:
>> 
>> 
> 55
>> 
>> 
>> 
>> 
>> 
>>   Please respond to user
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> The easiest way to execute an HTTP POST in a Pivot application is by
> using
>> the org.apache.pivot.web.PostQuery class. Here are a couple examples:
>> 
>> 
>> 
> http://svn.apache.org/repos/asf/pivot/trunk/demos/src/org/apache/pivot/demos
> 
>> /rest/
>> 
>> 
>> 
>> 
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/t
> 
>> utorials/webqueries/
>> 
>> 
>> The first one is a simple application that demonstrates unit testing a
> REST
>> service using web queries. The second one is a complete REST client
>> application. It will be part of the Pivot tutorial for Pivot 1.5.1. The
>> tutorial documentation does not exist yet, but the code should work OK.
>> 
>> Let me know if you have any questions about either example. Note that
> they
>> both use JSONSerializer to send and receive data - if you need to post
>> arbitrary file content, you may want to consider using an instance of
>> org.apache.pivot.io.FileSerializer instead.
>> 
>> G
>> 
>> On Jun 8, 2010, at 11:22 PM, kenjiang@sz.murata.com.cn wrote:
>> 
>>> 
>>> Hi All,
>>> 
>>> Is there any example for post file and parameter to web server by pivot.
>>> I check the pivot API doc,but seems pivot 1.5 can't do that.
>>> Does we need use our custom API do it like (Apache httpclient)?
>>> Please advise.
>>> 
>>> Best regards,
>>> Ken Jiang
>>> 
>>> *******************************************
>>> Murata Electronics Trading  (Shenzhen) Co.,Ltd
>>> Tel:86-755-82847251
>>> E-mail:kenjiang@sz.murata.com.cn
>>> *******************************************
>>> 
>> 
>> 
>> 
> 
> <pic06334.gif>


Re: How to post file by pivot.

Posted by ke...@sz.murata.com.cn.
Hi Alejandro,
Thank you in advance.
I get the hint for my problems.
Below is simple code.

But after I execute,the location is null.
PostQuery postQuery1 = new PostQuery("localhost", 8080,
"/pivot-tutorials/fileupload.jsp",false);
            postQuery1.setValue("A");
            URL location = postQuery1.execute();

Actually,I can use access this url.

(Embedded image moved to file: pic06334.gif)
I use the debuger and I found getStatus is Status.OK(200) and not equal
Status.CREATED(201).
|--------------------------------------------------------------------------|
| PostQuery.java,                                                          |
|                                                                          |
|   public URL execute() throws QueryException {                           |
|        URL valueLocation = null;                                         |
|                                                                          |
|        execute(METHOD, value);                                           |
|                                                                          |
|        if (getStatus() == Status.CREATED) {                              |
|--------------------------------------------------------------------------|


Best regards,
Ken Jiang

*******************************************
Murata Electronics Trading  (Shenzhen) Co.,Ltd
Tel:86-755-82847251
E-mail:kenjiang@sz.murata.com.cn
*******************************************


                                                                                                                     
  From:       Greg Brown <gk...@mac.com>                                                                           
                                                                                                                     
  To:         user@pivot.apache.org                                                                                  
                                                                                                                     
  Date:       06/11/2010 11:51                                                                                       
                                                                                                                     
  Subject:    Re: How to post file by pivot.                                                                         
                                                                                                                     





Great example, Alejandro.

Ken, note that pivot-web-1.5.jar, which contains everything you need to
execute web queries, is 33k in size. HttpClient requires the following
libraries, totaling 593k:

httpclient-4.0.1.jar
httpcore-4.0.1.jar
commons-logging-1.1.1.jar
commons-codec-1.4.jar

pivot-web-1.5.jar does require pivot-core-1.5.jar (229k), but WTK already
requires this library, so the net addition to include web query support in
a Pivot app is 33k.

G


On Jun 10, 2010, at 10:50 PM, Alejandro Vilar wrote:

> Hi Ken, as Greg mentioned in Pivot 1.5 there is a new class for files
> manipulation related to web queries (FileSerializer).
>
> You can try something like this on client side:
>
> import java.io.File;
> import java.net.URL;
> import org.apache.pivot.io.FileSerializer;
> import org.apache.pivot.web.*;
>
> //...
> String hostname = "fileserver.com";
> try {
>    //post
>    File fileToSend = new File("sample.jpg");
>    PostQuery postQuery = new PostQuery(hostname, "/files");
>    postQuery.getParameters().put("filename", fileToSend.getName());
>    postQuery.setSerializer(new FileSerializer());
>    postQuery.setValue(fileToSend);
>    URL url = postQuery.execute();
>
>    //get
>    GetQuery getQuery = new GetQuery(hostname, url.getPath());
>    getQuery.setSerializer(new FileSerializer());
>    File receivedFile = (File) getQuery.execute();
>
> } catch (QueryException e) {
>    e.printStackTrace();
> }
> //...
> Hope this helps,
> Alejandro
>
> -----Original Message-----
> From: kenjiang@sz.murata.com.cn [mailto:kenjiang@sz.murata.com.cn]
> Sent: Jueves, 10 de Junio de 2010 10:14 p.m.
> To: user@pivot.apache.org
> Subject: Re: How to post file by pivot.
>
> Hi Greg,
>
> Thank you for your information.
> For post parameter is ok.But I would like to post arbitrary file like
some
> JPG,GIF to existing web server.
> For Example,
> 1.User select the files.
> 2.Post to server side JSP.
> 3.Save files in server side.
>
> In normal web application,we easily to do that.
> I also use HTTPCLIENT to similar this action.It's Ok.
> but is there simple way to use pivot function do that?I wouldn't like
> include many third party lib in clinet JAR.
> Since they may effect the loading applet time.
>
>
>
> Best regards,
> Ken Jiang
>
> *******************************************
> Murata Electronics Trading  (Shenzhen) Co.,Ltd
> Tel:86-755-82847251
> E-mail:kenjiang@sz.murata.com.cn
> *******************************************
>
>
>
>
>
>
>
>
>    Re: How to post file by pivot.
>
>
>
>
>
>    Greg Brown
>
>                to:
>
>                  user
>
>
06/
>
>
09/
>
>
201
>
>
0
>
>
20:
>
>
55
>
>
>
>
>
>    Please respond to user
>
>
>
>
>
>
>
>
>
>
>
>
>
> The easiest way to execute an HTTP POST in a Pivot application is by
using
> the org.apache.pivot.web.PostQuery class. Here are a couple examples:
>
>
>
http://svn.apache.org/repos/asf/pivot/trunk/demos/src/org/apache/pivot/demos

> /rest/
>
>
>
>
http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/t

> utorials/webqueries/
>
>
> The first one is a simple application that demonstrates unit testing a
REST
> service using web queries. The second one is a complete REST client
> application. It will be part of the Pivot tutorial for Pivot 1.5.1. The
> tutorial documentation does not exist yet, but the code should work OK.
>
> Let me know if you have any questions about either example. Note that
they
> both use JSONSerializer to send and receive data - if you need to post
> arbitrary file content, you may want to consider using an instance of
> org.apache.pivot.io.FileSerializer instead.
>
> G
>
> On Jun 8, 2010, at 11:22 PM, kenjiang@sz.murata.com.cn wrote:
>
>>
>> Hi All,
>>
>> Is there any example for post file and parameter to web server by pivot.
>> I check the pivot API doc,but seems pivot 1.5 can't do that.
>> Does we need use our custom API do it like (Apache httpclient)?
>> Please advise.
>>
>> Best regards,
>> Ken Jiang
>>
>> *******************************************
>> Murata Electronics Trading  (Shenzhen) Co.,Ltd
>> Tel:86-755-82847251
>> E-mail:kenjiang@sz.murata.com.cn
>> *******************************************
>>
>
>
>


Re: How to post file by pivot.

Posted by Greg Brown <gk...@mac.com>.
Great example, Alejandro. 

Ken, note that pivot-web-1.5.jar, which contains everything you need to execute web queries, is 33k in size. HttpClient requires the following libraries, totaling 593k:

httpclient-4.0.1.jar
httpcore-4.0.1.jar
commons-logging-1.1.1.jar
commons-codec-1.4.jar

pivot-web-1.5.jar does require pivot-core-1.5.jar (229k), but WTK already requires this library, so the net addition to include web query support in a Pivot app is 33k.

G


On Jun 10, 2010, at 10:50 PM, Alejandro Vilar wrote:

> Hi Ken, as Greg mentioned in Pivot 1.5 there is a new class for files
> manipulation related to web queries (FileSerializer).
> 
> You can try something like this on client side:
> 
> import java.io.File;
> import java.net.URL;
> import org.apache.pivot.io.FileSerializer;
> import org.apache.pivot.web.*;
> 
> //...
> String hostname = "fileserver.com";
> try {
>    //post
>    File fileToSend = new File("sample.jpg");
>    PostQuery postQuery = new PostQuery(hostname, "/files");
>    postQuery.getParameters().put("filename", fileToSend.getName());
>    postQuery.setSerializer(new FileSerializer());
>    postQuery.setValue(fileToSend);
>    URL url = postQuery.execute();
> 
>    //get
>    GetQuery getQuery = new GetQuery(hostname, url.getPath());
>    getQuery.setSerializer(new FileSerializer());
>    File receivedFile = (File) getQuery.execute(); 
> 
> } catch (QueryException e) {
>    e.printStackTrace();
> }
> //...
> Hope this helps,
> Alejandro
> 
> -----Original Message-----
> From: kenjiang@sz.murata.com.cn [mailto:kenjiang@sz.murata.com.cn] 
> Sent: Jueves, 10 de Junio de 2010 10:14 p.m.
> To: user@pivot.apache.org
> Subject: Re: How to post file by pivot.
> 
> Hi Greg,
> 
> Thank you for your information.
> For post parameter is ok.But I would like to post arbitrary file like some
> JPG,GIF to existing web server.
> For Example,
> 1.User select the files.
> 2.Post to server side JSP.
> 3.Save files in server side.
> 
> In normal web application,we easily to do that.
> I also use HTTPCLIENT to similar this action.It's Ok.
> but is there simple way to use pivot function do that?I wouldn't like
> include many third party lib in clinet JAR.
> Since they may effect the loading applet time.
> 
> 
> 
> Best regards,
> Ken Jiang
> 
> *******************************************
> Murata Electronics Trading  (Shenzhen) Co.,Ltd
> Tel:86-755-82847251
> E-mail:kenjiang@sz.murata.com.cn
> *******************************************
> 
> 
> 
> 
> 
> 
> 
> 
>    Re: How to post file by pivot.
> 
> 
> 
> 
> 
>    Greg Brown
> 
>                to:
> 
>                  user
> 
>                                                                         06/
> 
>                                                                         09/
> 
>                                                                         201
> 
>                                                                           0
> 
>                                                                         20:
> 
>                                                                          55
> 
> 
> 
> 
> 
>    Please respond to user
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> The easiest way to execute an HTTP POST in a Pivot application is by using
> the org.apache.pivot.web.PostQuery class. Here are a couple examples:
> 
> 
> http://svn.apache.org/repos/asf/pivot/trunk/demos/src/org/apache/pivot/demos
> /rest/
> 
> 
> 
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/t
> utorials/webqueries/
> 
> 
> The first one is a simple application that demonstrates unit testing a REST
> service using web queries. The second one is a complete REST client
> application. It will be part of the Pivot tutorial for Pivot 1.5.1. The
> tutorial documentation does not exist yet, but the code should work OK.
> 
> Let me know if you have any questions about either example. Note that they
> both use JSONSerializer to send and receive data - if you need to post
> arbitrary file content, you may want to consider using an instance of
> org.apache.pivot.io.FileSerializer instead.
> 
> G
> 
> On Jun 8, 2010, at 11:22 PM, kenjiang@sz.murata.com.cn wrote:
> 
>> 
>> Hi All,
>> 
>> Is there any example for post file and parameter to web server by pivot.
>> I check the pivot API doc,but seems pivot 1.5 can't do that.
>> Does we need use our custom API do it like (Apache httpclient)?
>> Please advise.
>> 
>> Best regards,
>> Ken Jiang
>> 
>> *******************************************
>> Murata Electronics Trading  (Shenzhen) Co.,Ltd
>> Tel:86-755-82847251
>> E-mail:kenjiang@sz.murata.com.cn
>> *******************************************
>> 
> 
> 
> 


RE: How to post file by pivot.

Posted by Alejandro Vilar <al...@synacom.com.bo>.
Hi Ken, as Greg mentioned in Pivot 1.5 there is a new class for files
manipulation related to web queries (FileSerializer).

You can try something like this on client side:

import java.io.File;
import java.net.URL;
import org.apache.pivot.io.FileSerializer;
import org.apache.pivot.web.*;

//...
String hostname = "fileserver.com";
try {
    //post
    File fileToSend = new File("sample.jpg");
    PostQuery postQuery = new PostQuery(hostname, "/files");
    postQuery.getParameters().put("filename", fileToSend.getName());
    postQuery.setSerializer(new FileSerializer());
    postQuery.setValue(fileToSend);
    URL url = postQuery.execute();

    //get
    GetQuery getQuery = new GetQuery(hostname, url.getPath());
    getQuery.setSerializer(new FileSerializer());
    File receivedFile = (File) getQuery.execute(); 

} catch (QueryException e) {
    e.printStackTrace();
}
//...
Hope this helps,
Alejandro

-----Original Message-----
From: kenjiang@sz.murata.com.cn [mailto:kenjiang@sz.murata.com.cn] 
Sent: Jueves, 10 de Junio de 2010 10:14 p.m.
To: user@pivot.apache.org
Subject: Re: How to post file by pivot.

Hi Greg,

Thank you for your information.
For post parameter is ok.But I would like to post arbitrary file like some
JPG,GIF to existing web server.
For Example,
1.User select the files.
2.Post to server side JSP.
3.Save files in server side.

In normal web application,we easily to do that.
I also use HTTPCLIENT to similar this action.It's Ok.
but is there simple way to use pivot function do that?I wouldn't like
include many third party lib in clinet JAR.
Since they may effect the loading applet time.



Best regards,
Ken Jiang

*******************************************
Murata Electronics Trading  (Shenzhen) Co.,Ltd
Tel:86-755-82847251
E-mail:kenjiang@sz.murata.com.cn
*******************************************


 

 

 

    Re: How to post file by pivot.

 

 

    Greg Brown

                to:

                  user

                                                                         06/

                                                                         09/

                                                                         201

                                                                           0

                                                                         20:

                                                                          55

 

 

    Please respond to user

 

 

 







The easiest way to execute an HTTP POST in a Pivot application is by using
the org.apache.pivot.web.PostQuery class. Here are a couple examples:


http://svn.apache.org/repos/asf/pivot/trunk/demos/src/org/apache/pivot/demos
/rest/



http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/t
utorials/webqueries/


The first one is a simple application that demonstrates unit testing a REST
service using web queries. The second one is a complete REST client
application. It will be part of the Pivot tutorial for Pivot 1.5.1. The
tutorial documentation does not exist yet, but the code should work OK.

Let me know if you have any questions about either example. Note that they
both use JSONSerializer to send and receive data - if you need to post
arbitrary file content, you may want to consider using an instance of
org.apache.pivot.io.FileSerializer instead.

G

On Jun 8, 2010, at 11:22 PM, kenjiang@sz.murata.com.cn wrote:

>
> Hi All,
>
> Is there any example for post file and parameter to web server by pivot.
> I check the pivot API doc,but seems pivot 1.5 can't do that.
> Does we need use our custom API do it like (Apache httpclient)?
> Please advise.
>
> Best regards,
> Ken Jiang
>
> *******************************************
> Murata Electronics Trading  (Shenzhen) Co.,Ltd
> Tel:86-755-82847251
> E-mail:kenjiang@sz.murata.com.cn
> *******************************************
>




Re: How to post file by pivot.

Posted by ke...@sz.murata.com.cn.
Hi Greg,

Thank you for your information.
For post parameter is ok.But I would like to post arbitrary file like some
JPG,GIF to existing web server.
For Example,
1.User select the files.
2.Post to server side JSP.
3.Save files in server side.

In normal web application,we easily to do that.
I also use HTTPCLIENT to similar this action.It's Ok.
but is there simple way to use pivot function do that?I wouldn't like
include many third party lib in clinet JAR.
Since they may effect the loading applet time.



Best regards,
Ken Jiang

*******************************************
Murata Electronics Trading  (Shenzhen) Co.,Ltd
Tel:86-755-82847251
E-mail:kenjiang@sz.murata.com.cn
*******************************************


                                                                             
                                                                             
                                                                             
    Re: How to post file by pivot.                                           
                                                                             
                                                                             
    Greg Brown                                                               
                to:                                                          
                  user                                                       
                                                                         06/ 
                                                                         09/ 
                                                                         201 
                                                                           0 
                                                                         20: 
                                                                          55 
                                                                             
                                                                             
    Please respond to user                                                   
                                                                             
                                                                             
                                                                             






The easiest way to execute an HTTP POST in a Pivot application is by using
the org.apache.pivot.web.PostQuery class. Here are a couple examples:


http://svn.apache.org/repos/asf/pivot/trunk/demos/src/org/apache/pivot/demos/rest/



http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/


The first one is a simple application that demonstrates unit testing a REST
service using web queries. The second one is a complete REST client
application. It will be part of the Pivot tutorial for Pivot 1.5.1. The
tutorial documentation does not exist yet, but the code should work OK.

Let me know if you have any questions about either example. Note that they
both use JSONSerializer to send and receive data - if you need to post
arbitrary file content, you may want to consider using an instance of
org.apache.pivot.io.FileSerializer instead.

G

On Jun 8, 2010, at 11:22 PM, kenjiang@sz.murata.com.cn wrote:

>
> Hi All,
>
> Is there any example for post file and parameter to web server by pivot.
> I check the pivot API doc,but seems pivot 1.5 can't do that.
> Does we need use our custom API do it like (Apache httpclient)?
> Please advise.
>
> Best regards,
> Ken Jiang
>
> *******************************************
> Murata Electronics Trading  (Shenzhen) Co.,Ltd
> Tel:86-755-82847251
> E-mail:kenjiang@sz.murata.com.cn
> *******************************************
>




Re: How to post file by pivot.

Posted by Greg Brown <gk...@mac.com>.
The easiest way to execute an HTTP POST in a Pivot application is by using the org.apache.pivot.web.PostQuery class. Here are a couple examples:

  http://svn.apache.org/repos/asf/pivot/trunk/demos/src/org/apache/pivot/demos/rest/

  http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/

The first one is a simple application that demonstrates unit testing a REST service using web queries. The second one is a complete REST client application. It will be part of the Pivot tutorial for Pivot 1.5.1. The tutorial documentation does not exist yet, but the code should work OK.

Let me know if you have any questions about either example. Note that they both use JSONSerializer to send and receive data - if you need to post arbitrary file content, you may want to consider using an instance of org.apache.pivot.io.FileSerializer instead.

G

On Jun 8, 2010, at 11:22 PM, kenjiang@sz.murata.com.cn wrote:

> 
> Hi All,
> 
> Is there any example for post file and parameter to web server by pivot.
> I check the pivot API doc,but seems pivot 1.5 can't do that.
> Does we need use our custom API do it like (Apache httpclient)?
> Please advise.
> 
> Best regards,
> Ken Jiang
> 
> *******************************************
> Murata Electronics Trading  (Shenzhen) Co.,Ltd
> Tel:86-755-82847251
> E-mail:kenjiang@sz.murata.com.cn
> *******************************************
> 


Re: How to post file by pivot.

Posted by Denis Kononenko <de...@yahoo.com>.
мама звонила. чот грит с вылетом жопа. пришлось обращаться в посольство РФ.вроде как завтра обещали утром ее отправить

--- On Tue, 6/8/10, kenjiang@sz.murata.com.cn <ke...@sz.murata.com.cn> wrote:

From: kenjiang@sz.murata.com.cn <ke...@sz.murata.com.cn>
Subject: How to post file by pivot.
To: user@pivot.apache.org
Date: Tuesday, June 8, 2010, 8:22 PM


Hi All,

Is there any example for post file and parameter to web server by pivot.
I check the pivot API doc,but seems pivot 1.5 can't do that.
Does we need use our custom API do it like (Apache httpclient)?
Please advise.

Best regards,
Ken Jiang

*******************************************
Murata Electronics Trading  (Shenzhen) Co.,Ltd
Tel:86-755-82847251
E-mail:kenjiang@sz.murata.com.cn
*******************************************