You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Milan Křápek <He...@seznam.cz> on 2008/06/03 09:31:23 UTC

Upload/Download file

Hi, 
  I need your help. I am trying to upload and download some files via the Wicket presentation layer, but I realy do not know how to do it. I try to get some inspiration from upload example on wicket pages, but this is not what I want.

  Here is the description of my problem:
I have some standalone application that collects some data from users and generates some files from it. Each hour this application generates http request that contains some parameters and the content of the file. This request was processed on server by PHP script that stores the file on disk and fills database with new record about this file. Now I need to access this files to another users via internet so I decided to build wicket application and I want to include the the previous PHP script to wicket pages. So I want to have some wicket page that will process the request with file and send the file stream and parameters to the application layer that stores it to database.

  But I do not know how to do it. Plase can anybody give me any advice if the wicket support this behavior or where to take some inspiration?

  The second problem is how to enable the downloading of these files. I cannot just give a link to the wicket page, because I need to check authority of the user (if he can see the requested file). So I want to give to the wicket page some button tahat starts an action that checks the user authority and than fill the http response with the file. If I have seen some example for uploading files via wicket I did not see any comment or example about downloading. 
 
  Please can you give me any point to some article or wicket javadoc that could help me?

Thanks for any advice

Milan   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Upload/Download file

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Add it to the wiki:)

Milan K?ápek wrote:
> I have it. It was hidden under the wicket request. It can be done by cast the request to IMultipartWebRequest. This request then can access the file stored in the HTTP request.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Upload/Download file

Posted by Milan Křápek <He...@seznam.cz>.
I have it. It was hidden under the wicket request. It can be done by cast the request to IMultipartWebRequest. This request then can access the file stored in the HTTP request.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Upload/Download file

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.

Milan K?ápek wrote:
> As I write the HTTP request that contains the file is generated by standalone application. And the application do not need graphical interface. It is very simple to get file contained in HTTP request in PHP, I have hoped that wicket have some easy access to this data too.
>
>   
Im just not sure, never had the need todo it directly..
> To your advice to search through the source code of the component. I hope I never get to that but it seems that it is the only way I  can use :o(
>   
What's the difference, it's probably very clear to you. I've looked at 
how people do stuff in source code a million times, it's therein the 
truth lies. Otherwise there could be something in the wiki too..
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Upload/Download file

Posted by Milan Křápek <He...@seznam.cz>.
As I write the HTTP request that contains the file is generated by standalone application. And the application do not need graphical interface. It is very simple to get file contained in HTTP request in PHP, I have hoped that wicket have some easy access to this data too.

To your advice to search through the source code of the component. I hope I never get to that but it seems that it is the only way I  can use :o(

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Upload/Download file

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Why do you need todo it that way, cant you just change it? Otherwise i'd 
look into how that wicket component from the example does it.

regards

Milan K?ápek wrote:
> Thanks for your respnse. Yes I know I have seen this example, but as I wrote this in not the think I want to do. In that example you get access to the file through the wicket component. But in my case the file is send to my application as HTTP request (not using any wicket form), so I need to get access to the from direct through the wicket request. Or am I wrong?
>
> Milan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Upload/Download file

Posted by Milan Křápek <He...@seznam.cz>.
Thanks for your respnse. Yes I know I have seen this example, but as I wrote this in not the think I want to do. In that example you get access to the file through the wicket component. But in my case the file is send to my application as HTTP request (not using any wicket form), so I need to get access to the from direct through the wicket request. Or am I wrong?

Milan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Upload/Download file

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
there are an example on this on the wicket examples...

http://www.wicket-library.com/wicket-examples/upload/single

Milan K?ápek wrote:
> Well I think I have the way how to let users to download the files from server. When the request comes I just take the file from database, set the right content type of the response and then I get the outputStream of the Response and fill it with the file. Is it true? Or am I wrong?
>
> And what about the upload. How can I get to the inputStream of the http request that contains the file stream??
>
> Thanks
>
> Milan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Upload/Download file

Posted by Milan Křápek <He...@seznam.cz>.
Well I think I have the way how to let users to download the files from server. When the request comes I just take the file from database, set the right content type of the response and then I get the outputStream of the Response and fill it with the file. Is it true? Or am I wrong?

And what about the upload. How can I get to the inputStream of the http request that contains the file stream??

Thanks

Milan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org