You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by vijay shanker <vi...@gmail.com> on 2009/11/04 18:26:29 UTC

File upload: not identified content type.

Hello friends;

I am using commons file upload library to upload files. I have been noticing
some time my library does not get file content type correct. For such a file
it saves *application*/*octet*-*stream. *

Can any body describe how it does happens?

If some of you have known for such a situation. Please share the
information.
**
Regards,
Vijay Shanker Dubey
Ph: +91-9818311884

Re: File upload: not identified content type.

Posted by Niall Pemberton <ni...@gmail.com>.
AIUI it gets it from the request headers:

http://commons.apache.org/fileupload/xref/org/apache/commons/fileupload/FileUploadBase.html#993

Niall

On Wed, Nov 4, 2009 at 5:26 PM, vijay shanker <vi...@gmail.com> wrote:
> Hello friends;
>
> I am using commons file upload library to upload files. I have been noticing
> some time my library does not get file content type correct. For such a file
> it saves *application*/*octet*-*stream. *
>
> Can any body describe how it does happens?
>
> If some of you have known for such a situation. Please share the
> information.
> **
> Regards,
> Vijay Shanker Dubey
> Ph: +91-9818311884
>

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


Re: File upload: not identified content type.

Posted by vijay shanker <vi...@gmail.com>.
Thanks guys;

I am using spring-mvc for my web application. So have been looking in to the
spring lib to get some thing relevant. But sorry to say; I have got no
results.

I think finding with file extension will do and will save me every time.

May be spring lib has some thing to support me; any body can point!

Regards,
Vijay Shanker Dubey



On Fri, Nov 6, 2009 at 11:00 AM, Raghuveer.V <ra...@infotechsw.com>wrote:

> Please validate on client side if file is uploaded and in serverside side
> check for extension of file before checking application/octet-stream
>
>
> if(file!=null){
>                strFileName = file.getFileName();
>                stContentType = file.getContentType();
>
>  }
>
> if ( strFileName != null && !strFileName.trim().equalsIgnoreCase("")) {
> //if
> filename not null
>
> strExtension=strFileName.substring(strFileName.lastIndexOf(".")+1);
> strExtension=strExtension.toUpperCase();
> if("application/octet-stream".equalsIgnoreCase(stContentType)
>  ){
> /////process///
> }
> }
>
> Regards,
> Raghuveer
>
> -----Original Message-----
> From: vijay shanker [mailto:vijay.shad@gmail.com]
> Sent: Wednesday, November 04, 2009 10:56 PM
> To: user
> Subject: File upload: not identified content type.
>
> Hello friends;
>
> I am using commons file upload library to upload files. I have been
> noticing
> some time my library does not get file content type correct. For such a
> file
> it saves *application*/*octet*-*stream. *
>
> Can any body describe how it does happens?
>
> If some of you have known for such a situation. Please share the
> information.
> **
> Regards,
> Vijay Shanker Dubey
> Ph: +91-9818311884
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

RE: File upload: not identified content type.

Posted by "Raghuveer.V" <ra...@infotechsw.com>.
Please validate on client side if file is uploaded and in serverside side
check for extension of file before checking application/octet-stream


if(file!=null){
                strFileName = file.getFileName();
                stContentType = file.getContentType();

 }

if ( strFileName != null && !strFileName.trim().equalsIgnoreCase("")) { //if
filename not null
 
strExtension=strFileName.substring(strFileName.lastIndexOf(".")+1);
strExtension=strExtension.toUpperCase();
if("application/octet-stream".equalsIgnoreCase(stContentType)
  ){
/////process///
}
}

Regards,
Raghuveer

-----Original Message-----
From: vijay shanker [mailto:vijay.shad@gmail.com] 
Sent: Wednesday, November 04, 2009 10:56 PM
To: user
Subject: File upload: not identified content type.

Hello friends;

I am using commons file upload library to upload files. I have been noticing
some time my library does not get file content type correct. For such a file
it saves *application*/*octet*-*stream. *

Can any body describe how it does happens?

If some of you have known for such a situation. Please share the
information.
**
Regards,
Vijay Shanker Dubey
Ph: +91-9818311884


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