Re: Storing and retrieving user uploaded images

2011-02-19 Thread Henrique Boregio
Thanks everyone, I was able to fix it by doing:

When uploading a picture:
WebApplication.get().getServletContext().getRealPath("") + "/" +
"profilePics" + "/";

When retrieving a picture:
WebApplication.get().getServletContext().getContextPath() + "/" +
"profilePics" + "/" + userId + "/";

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



Re: Storing and retrieving user uploaded images

2011-02-18 Thread msj121

You can see how this works for you:

String path =  WebApplication.get().getServletContext().getRealPath("");
Folder uploadFolder = new Folder(path+"/uploads");

public String getURLFolder(){
return
getServletContext().getContextPath()+uploadFolder.getPath().replace(path,
"");
}


I remember writing this a long time ago, looking at it now, not sure why or
what the difference is "getRealPath("")" and "getContextPath()", and not
sure if Wicket 1.5 changed this code, but this worked for me, though I hope
to migrate to a database that way there should be much much less issue in
regard to scaling to 20 servers... where sharing a database and backing up
is readily done and improved whereas sharing files probably not

Matthew
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Storing-and-retrieving-user-uploaded-images-tp3312735p3313112.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Storing and retrieving user uploaded images

2011-02-18 Thread James Carman
On Fri, Feb 18, 2011 at 9:21 AM, Martin Grigorov  wrote:
> if you need the uploads to be persistent (to be there after server restart)
> then create your own folder (e.g. /apps/myapp/image-uploads)
>

Or a database.

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



Re: Storing and retrieving user uploaded images

2011-02-18 Thread Martin Grigorov
don't use "." (current folder) in web apps
better user servletcontext.getAttribute("javax.servlet.context.tempdir") and
use that as root folder

if you need the uploads to be persistent (to be there after server restart)
then create your own folder (e.g. /apps/myapp/image-uploads)

On Fri, Feb 18, 2011 at 4:09 PM, Henrique Boregio wrote:

> Hi, I'm having trouble storing user uploaded images.
>
> In my WicketApplication class, I setup a folder to store users
> pictures, so I end up with a folder structure similar to this:
> ROOT FOLDER
> - user1_folder (pic1.jpg, pic2.jpg, etc...)
> - user2_folder ( ... )
> - ...
>
> The issue I am having is that this folder is created at
> "src/main/java" (I am using maven). When I run the application, the
> Root actually becomes the "webapp" folder, so the relative path
> changes.
>
> How can I unify this folder so that its absolute path remains the same
> no matter where it is called from?
>
> My current solutions is to hard-code it like: "/src/main/java" +
> userFolderName, but that's no the best way I'm sure.
>
> Thanks!
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Storing and retrieving user uploaded images

2011-02-18 Thread Henrique Boregio
Hi, I'm having trouble storing user uploaded images.

In my WicketApplication class, I setup a folder to store users
pictures, so I end up with a folder structure similar to this:
ROOT FOLDER
- user1_folder (pic1.jpg, pic2.jpg, etc...)
- user2_folder ( ... )
- ...

The issue I am having is that this folder is created at
"src/main/java" (I am using maven). When I run the application, the
Root actually becomes the "webapp" folder, so the relative path
changes.

How can I unify this folder so that its absolute path remains the same
no matter where it is called from?

My current solutions is to hard-code it like: "/src/main/java" +
userFolderName, but that's no the best way I'm sure.

Thanks!

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