File upload: not identified content type.

4 messages Options
Embed this post
Permalink
vijay shanker

File upload: not identified content type.

Reply Threaded More More options
Print post
Permalink
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
Niall Pemberton

Re: File upload: not identified content type.

Reply Threaded More More options
Print post
Permalink
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 <[hidden email]> 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: [hidden email]
For additional commands, e-mail: [hidden email]

raghuveerv

RE: File upload: not identified content type.

Reply Threaded More More options
Print post
Permalink
In reply to this post by vijay shanker
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:[hidden email]]
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: [hidden email]
For additional commands, e-mail: [hidden email]

vijay shanker

Re: File upload: not identified content type.

Reply Threaded More More options
Print post
Permalink
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 <[hidden email]>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:[hidden email]]
> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>