You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Pierre Gilquin <pg...@bluewin.ch> on 2008/03/05 14:11:12 UTC
Upload file
I try to modify the upload example (http://www.wicket-library.com/wicket-examples/upload/single) for my own need.
I would like to be able to upload the file in a directory under my context (ie. tomcat_install/webapps/MyApp/DownloadedFiles) and generate the corresponding internet url for the files (ie. http://localhost:8080/MyApp/DownloadedFiles/file1)
How can I get the local and internet paths from my appli. ?
Thanks in advance
Pierre
Re: Upload file
Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
great:) and np..
Pierre G wrote:
> ExternalLink works great with relative path (/DownloadedFiles/file1)
> and I was able to access the context path
> using getServletContext().getRealPath("/") in Application.init
>
> Thanks
>
> Pierre
>
>
> Nino.Martinez wrote:
>
>>
>>
>> folder.getFiles()[1].toURL() should give the direct url for the file, now
>> if you want to serve if through wicket then you got to use resources..
>> Otherwise just create some externalLinks and that should be it..
>>
>>
>>
>>
>
>
--
-Wicket for love
-Jme for fun
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 file
Posted by Pierre G <pg...@bluewin.ch>.
ExternalLink works great with relative path (/DownloadedFiles/file1)
and I was able to access the context path
using getServletContext().getRealPath("/") in Application.init
Thanks
Pierre
Nino.Martinez wrote:
>
>
>
>
> folder.getFiles()[1].toURL() should give the direct url for the file, now
> if you want to serve if through wicket then you got to use resources..
> Otherwise just create some externalLinks and that should be it..
>
>
>
--
View this message in context: http://www.nabble.com/Upload-file-tp15849850p15868265.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Upload file
Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Taken from the example you mention:
|File newFile = new File(getUploadFolder(), upload.getClientFileName());
||newFile.createNewFile();
upload.writeTo(newFile);
Above writes to the file..
This lets you traverse through the directory..:
|
private Folder uploadFolder = null;
uploadFolder = new Folder(System.getProperty("mysubFolder "), "wicket-uploads");
// Ensure folder exists
uploadFolder.mkdirs();
folder.getFiles()[1].toURL() should give the direct url for the file, now if you want to serve if through wicket then you got to use resources.. Otherwise just create some externalLinks and that should be it..
regards
Pierre G wrote:
> Thanks Nino,
>
> Sorry, I dont understand. Please be more detailed.
> I try to use Folder from util.file package
> uploadFolder = new Folder(?, "DownloadedFiles");
> then can I use the folder as resource ? how ?
>
> I still dont have any idea how to have my uploadFolder in the context ....
>
>
> Nino.Martinez wrote:
>
>> Theres file in utils package.. Producing a url for that could be
>> mounting a resource and using the urlfor...
>>
>> Pierre Gilquin wrote:
>>
>>> I try to modify the upload example
>>> (http://www.wicket-library.com/wicket-examples/upload/single) for my own
>>> need.
>>> I would like to be able to upload the file in a directory under my
>>> context (ie. tomcat_install/webapps/MyApp/DownloadedFiles) and generate
>>> the corresponding internet url for the files (ie.
>>> http://localhost:8080/MyApp/DownloadedFiles/file1)
>>>
>>> How can I get the local and internet paths from my appli. ?
>>>
>>> Thanks in advance
>>>
>>>
>>> Pierre
>>>
>>>
>> --
>> -Wicket for love
>> -Jme for fun
>>
>> 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
>>
>>
>>
>>
>
>
--
-Wicket for love
-Jme for fun
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 file
Posted by Pierre G <pg...@bluewin.ch>.
Thanks Nino,
Sorry, I dont understand. Please be more detailed.
I try to use Folder from util.file package
uploadFolder = new Folder(?, "DownloadedFiles");
then can I use the folder as resource ? how ?
I still dont have any idea how to have my uploadFolder in the context ....
Nino.Martinez wrote:
>
> Theres file in utils package.. Producing a url for that could be
> mounting a resource and using the urlfor...
>
> Pierre Gilquin wrote:
>> I try to modify the upload example
>> (http://www.wicket-library.com/wicket-examples/upload/single) for my own
>> need.
>> I would like to be able to upload the file in a directory under my
>> context (ie. tomcat_install/webapps/MyApp/DownloadedFiles) and generate
>> the corresponding internet url for the files (ie.
>> http://localhost:8080/MyApp/DownloadedFiles/file1)
>>
>> How can I get the local and internet paths from my appli. ?
>>
>> Thanks in advance
>>
>>
>> Pierre
>>
>
> --
> -Wicket for love
> -Jme for fun
>
> 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
>
>
>
--
View this message in context: http://www.nabble.com/Upload-file-tp15849850p15852279.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Upload file
Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Theres file in utils package.. Producing a url for that could be
mounting a resource and using the urlfor...
Pierre Gilquin wrote:
> I try to modify the upload example (http://www.wicket-library.com/wicket-examples/upload/single) for my own need.
> I would like to be able to upload the file in a directory under my context (ie. tomcat_install/webapps/MyApp/DownloadedFiles) and generate the corresponding internet url for the files (ie. http://localhost:8080/MyApp/DownloadedFiles/file1)
>
> How can I get the local and internet paths from my appli. ?
>
> Thanks in advance
>
>
> Pierre
>
--
-Wicket for love
-Jme for fun
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