commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Awais Ahamed Bajwa" <awais.ba...@emirates.com>
Subject RE: Size of the list containing file items is null.
Date Sun, 29 Apr 2007 04:27:19 GMT
Isn't there anything available in the file upload component that can
tell the what type of content is being uploaded?



Regards

Awais Bajwa

Sr Software Engineer
MERCATOR - the IT division of the Emirates Group
Emirates Aviation College- First Floor Room 111 
DUBAI -United Arab Emirates
Tel:	+971-42-187997
Cell:	+971-50-8930159
awais.bajwa@emirates.com



-----Original Message-----
From: mfncooper@gmail.com [mailto:mfncooper@gmail.com] On Behalf Of
Martin Cooper
Sent: Saturday, April 28, 2007 8:33 PM
To: Jakarta Commons Users List
Subject: Re: Size of the list containing file items is null.

On 4/28/07, Awais Ahamed Bajwa <awais.bajwa@emirates.com> wrote:
>
> Worst thing is that I am getting "application/octet-stream" even for 
> html and PDF files ...I am sure what is happening .


That's up to the browser, or other client. I don't believe there's any
way to control or influence that. Your best bet is to analyse the
content as it's uploaded, to determine its true type.

--
Martin Cooper


-----Original Message-----
> From: Awais Ahamed Bajwa [mailto:awais.bajwa@emirates.com]
> Sent: Saturday, April 28, 2007 7:56 PM
> To: Jakarta Commons Users List
> Subject: RE: Size of the list containing file items is null.
>
> No problem I shall be working on this. Thanks for your emials, one 
> more concern I have is, I don't want the user to upload the .exe files

> using , so I am using the following
>
> if(fileItem1.getContentType().trim().equals("application/octet-stream"
> ))
>
> It works sometimes, but I have noticed, sometimes the above stands 
> true even for text files, is there any other way to find that the 
> uploaded file is an executable file? Obviulsy checking the file 
> extension is not enough ? Any idea?
>
>
>
>
>
> Regards
>
> Awais Bajwa
>
> Sr Software Engineer
> MERCATOR - the IT division of the Emirates Group Emirates Aviation
> College- First Floor Room 111 DUBAI -United Arab Emirates
> Tel:    +971-42-187997
> Cell:   +971-50-8930159
> awais.bajwa@emirates.com
>
>
>
> -----Original Message-----
> From: mfncooper@gmail.com [mailto:mfncooper@gmail.com] On Behalf Of 
> Martin Cooper
> Sent: Saturday, April 28, 2007 7:42 PM
> To: Jakarta Commons Users List
> Subject: Re: Size of the list containing file items is null.
>
> On 4/28/07, Awais Ahamed Bajwa <awais.bajwa@emirates.com> wrote:
> >
> > Martin,
> > I am really very confused, so far I concluded that If I deploy the 
> > applicaion on Tocmat it works and if I deploy it on WebLogic the 
> > fileItemsList returns me no list of items after 
> > parseRequest(HttpServletRequest). But my requiremetn is to deploy it

> > into weblogic. I am trying to find out any way..if you have any 
> > thing in your mind?
>
>
> Most likely your WebLogic instance is either configured to parse 
> uploads automatically, or configured to block upload requests as a 
> security policy.
> I'm not sufficiently familiar with WebLogic to tell you how to check 
> or change those settings, so you'll probably need to read the docs.
>
> --
> Martin Cooper
>
>
> Regards
> >
> > Awais Bajwa
> >
> > Sr Software Engineer
> > MERCATOR - the IT division of the Emirates Group Emirates Aviation
> > College- First Floor Room 111 DUBAI -United Arab Emirates
> > Tel:    +971-42-187997
> > Cell:   +971-50-8930159
> > awais.bajwa@emirates.com
> >
> >
> >
> > -----Original Message-----
> > From: mfncooper@gmail.com [mailto:mfncooper@gmail.com] On Behalf Of 
> > Martin Cooper
> > Sent: Saturday, April 28, 2007 6:51 PM
> > To: Jakarta Commons Users List
> > Subject: Re: Size of the list containing file items is null.
> >
> > On 4/28/07, Awais Ahamed Bajwa <awais.bajwa@emirates.com> wrote:
> > >
> > > Thanks Martin,
> > > But I am not consuming request anywhere, is it a bug in the 
> > > FileUpload
> >
> > > or what?
> >
> >
> > Are you sure the container is not consuming the stream before you 
> > get a chance to access it? Or that you are not causing the container

> > to consume it by trying to access request parameters? Have you 
> > looked at the request on the wire to make sure that it's 
> > well-formed? Have you verified that the max size you are setting is 
> > a meaningful value, or tried taking that line out (along with all 
> > the other lines that aren't
>
> > doing anything useful)?
> >
> > --
> > Martin Cooper
> >
> >
> > Martin Wrote:
> > >
> > >
> > > Please see the first entry in the FileUpload FAQ:
> > >
> > > http://jakarta.apache.org/commons/fileupload/faq.html
> > >
> > > Also:
> > >
> > > * Using FileUpload in a JSP page is not recommended. You should 
> > > use a servlet instead.
> > > * Your code is configuring diskFileItemFactory but never using it.
> > >
> > > --
> > > Martin Cooper
> > >
> > >
> > > On 4/27/07, Awais Ahamed Bajwa <awais.bajwa@emirates.com> wrote:
> > > >
> > > > Hi folks,
> > > >
> > > >
> > > > I have a JSP containing five ITEMs,
> > > >
> > > > Here is some code of the JSP:
> > > >
> > > > FORM:
> > > > <form name="frmPR" method="post"
> > > action="/upload/servlet/UploadServlet"
> > > > id="frmPR" enctype="multipart/form-data">
> > > >
> > > > FILE ITEMS:
> > > > <input name="document" id="document" type="file" 
> > > > class="textbox"/>
>
> > > > I have five items.
> > > >
> > > >
> > > > Here is my servlet code:
> > > >
> > > >                         File repositoryPath=null;
> > > > a                               List uploadedFiles=new
> ArrayList();
> > > >                                 HttpSession session = 
> > > > request.getSession(true);
> > > >                                 StringBuffer errors=new
> > > StringBuffer();
> > > >                         if
> > > > (!ServletFileUpload.isMultipartContent(request)){
> > > >
> > > > response.sendError(HttpServletResponse.SC_NO_CONTENT);
> > > >                                 }
> > > >                                 ServletFileUpload 
> > > > servletFileUpload = new ServletFileUpload(new
> DiskFileItemFactory());
> > > >                                 DiskFileItemFactory 
> > > > diskFileItemFactory = new DiskFileItemFactory();
> > > >
> > > > diskFileItemFactory.setSizeThreshold(40960); /* the unit is 
> > > > bytes
> */
> > > >                                 List fileItemsList = null;
> > > >
> > > >                                 repositoryPath = new 
> > > > File(Configurations.getRootFileLocation());
> > > >
> > > > diskFileItemFactory.setRepository(repositoryPath);
> > > >
> > > > servletFileUpload.setSizeMax(Configurations.getMaximumFileSize()
> > > > );
> > > > /* the unit is bytes */
> > > >
> > > >                                 try {
> > > >                                 fileItemsList = 
> > > > servletFileUpload.parseRequest(request);
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > When I  check the above FileItemList, it returns me the size 
> > > > equal
>
> > > > to 0
> > > >
> > > >
> > > > AM I Missing something:?????
> > > >
> > > >
> > > >
> > > > Regards
> > > > Awais Bajwa
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Regards
> > > >
> > > > Awais Bajwa
> > > >
> > > > Sr Software Engineer
> > > > MERCATOR - the IT division of the Emirates Group Emirates 
> > > > Aviation
> > > > College- First Floor Room 111 DUBAI -United Arab Emirates
> > > > Tel:    +971-42-187997
> > > > Cell:   +971-50-8930159
> > > > awais.bajwa@emirates.com
> > > >
> > > >
> > > >
> > > >
> > >
> > > ------------------------------------------------------------------
> > > --
> > > - To unsubscribe, e-mail:
> > > commons-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> > > commons-user-help@jakarta.apache.org
> > >
> > >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: 
> > commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: 
> > commons-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message