Wednesday, June 6, 2012

Re: Generate URL to image stored on server

I mean it's being stored on the server's local disk, specifically the user's home directory (the user running the servlet container process, e.g. C:\Documents and Settings\garyk) I tried for days to use relative directories(i.e. creating Java 'File' objects without a full path, so that they were placed in the working directory) but this never worked. I need to pass these uploaded images to other serverside classes, which use them to generate more images, and this always failed: I figured it was because the servlet was creating and destroying temp directories.

I was also warned never to rely on a 'working directory' when programming a servlet. Is this true?

I'm basically having an all torrid time with serverside file management. I don't know if I'm misunderstanding something fundamental because what I'm trying to do is quite simple but I simply cannot get it to work. I'll break it down and perhaps someone can help me.

1. User uploads image. This is stored and the URL returned. An image widget is constructed around this URL.
This part is functional as I use gwtupload, which has a clientside function to get the URL to the file just uploaded. I need to know how gwtupload generates this.

2. If it qualifies, this image may be cropped. The crop interface simply sends a coordinate pair to the server. A new cropped image is made, and the old image deleted.
I now need to return the URL of the new image. i.e. emulate what gwtupload does with Uploader.getFileUrl().

3. User can preview their work: the generation of previews relies on knowing the locations of the previously uploaded images.
The URL to the generated preview image must be returned so the browser can show  the image.

It seems so simple yet I repeatedly fail. I hope someone can offer some help.

On Wednesday, June 6, 2012 2:30:23 PM UTC+1, Derek wrote:
Not sure what you mean by "out-with," but I'll assume you mean you
upload it to what would be the war folder in a GWT project. If that's
true, use GWT.getHostPageBaseURL()+"image.png" to get the URL.

Derek

On Jun 6, 5:09 am, Gary <garyker...@googlemail.com> wrote:
> Hi,
>
> my application has a mechanism allowing a user to upload an image. This
> image is then stored on the server's disk. The important point to note is
> that the image is *out-with* the deployed WAR file.
>
> How do I generate a URL to access the image that has been uploaded? I want
> to return this URL after the upload is complete, so that I can construct an
> image widget around it.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/3pKi8u1WRisJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment