[fileupload] getting the simplest case to work

View: New views
2 Messages — Rating Filter:   Alert me  

[fileupload] getting the simplest case to work

by Chris Norris-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, I'm having trouble getting started with the FileUpload project.  I
have a service (hooked up via CXF) that does the following for a post
request:

                        boolean isMultipart = ServletFileUpload.isMultipartContent(request);
                        if(isMultipart)
                        {
                                ServletFileUpload upload = new ServletFileUpload();
                                FileItemIterator iterator = upload.getItemIterator(request);
                                System.out.println(iterator.hasNext());
                        }

The request is multipart, but the item iterator is always empty.  I've
tried submitting the request in three different ways: first from an
Adobe Lightroom plugin (which is what I'm working on), then from a mac
command-line curl call, then from a simple form, which I can reproduce
here:

<html>
<head><title>testing</testing></head>
<form
        action="http://cjn-pc.widen.com:8080/services/backdrop/backdropservice/upload/"
        method="POST"
        enctype="multipart/form-data">
        <input type="file"/>
        <input type="submit" value="test"/>
</form>
</html>

The item iterator always has zero items in it.  I've also tried
executing this "simplest case" code:
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List /* FileItem */ items = upload.parseRequest(request);

The items list is always empty.  I feel like I'm missing something
obvious here.  Anyone have any ideas?

Thanks,
Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: [fileupload] getting the simplest case to work

by Chris Norris-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ah... if a file input doesn't have a name, things break.  Good to know.

On Wed, May 14, 2008 at 3:34 PM, Chris Norris
<thechrisproject.lists@...> wrote:

> Hi, I'm having trouble getting started with the FileUpload project.  I
> have a service (hooked up via CXF) that does the following for a post
> request:
>
>                        boolean isMultipart = ServletFileUpload.isMultipartContent(request);
>                        if(isMultipart)
>                        {
>                                ServletFileUpload upload = new ServletFileUpload();
>                                FileItemIterator iterator = upload.getItemIterator(request);
>                                System.out.println(iterator.hasNext());
>                        }
>
> The request is multipart, but the item iterator is always empty.  I've
> tried submitting the request in three different ways: first from an
> Adobe Lightroom plugin (which is what I'm working on), then from a mac
> command-line curl call, then from a simple form, which I can reproduce
> here:
>
> <html>
> <head><title>testing</testing></head>
> <form
>        action="http://cjn-pc.widen.com:8080/services/backdrop/backdropservice/upload/"
>        method="POST"
>        enctype="multipart/form-data">
>        <input type="file"/>
>        <input type="submit" value="test"/>
> </form>
> </html>
>
> The item iterator always has zero items in it.  I've also tried
> executing this "simplest case" code:
> FileItemFactory factory = new DiskFileItemFactory();
> ServletFileUpload upload = new ServletFileUpload(factory);
> List /* FileItem */ items = upload.parseRequest(request);
>
> The items list is always empty.  I feel like I'm missing something
> obvious here.  Anyone have any ideas?
>
> Thanks,
> Chris
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...