on 07-16-2008 6:01 AM
Hello everyone,
I am currently implementing a filter in my code where I put a restriction that allows only a certain type of files to be accepted. One of them is the zip file type.
However, when I tried to read the mimetype of this zip file using the folloing API :
IWDResource.getResourceType().getHtmlMime(),
I get "application/octet-stream" which is the mime type of any binary file, and not "application/zip" which is the usual zip file mimetype.
Therefore it is difficult to identify whether the uploaded file is a zip file which we can operate on accordingly.
I need to know whether there is some way I can acheive this?
Hi,
You can check with File extension to know whether it is zip file or not.
Use this code.. Here "reso" is of binary type which is bound to data property of FileUpload UI Element.
IWDAttributeInfo attributeinfo=wdContext.getNodeInfo().getAttribute(wdContext.currentContextElement().RESOURCE);
IWDModifiableBinaryType binType=(IWDModifiableBinaryType)attributeinfo.getModifiableSimpleType();
String ext=binType.getMimeType().getFileExtension();
if(ext.equalsIgnoreCase("zip"))
// Code when it is zip file
else
// Code when it is not
Regards
LN
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dhruwat
there is a java-api called [truezip|https://truezip.dev.java.net]
in which you will find the following class ZipDetector, and the method "isZipFile".
[https://truezip.dev.java.net/javadoc-5/de/schlichtherle/io/ZipDetector.html#isZipFile(java.lang.String)]
Or something other but i don't know if you can find out that.
Every (regular) zip has the encoding "CP437". Maybe you can
check the outputstreams-encoding..?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.