Certain environments don't offer direct file access, which might not always make it possible to give people direct access to the File objects. We've deprecated the method for this reason.
The neat way of interacting with filedocuments via the Java Core API is by using input/outputstreams:
Core.getFileDocumentContent
If you want to read a zip file that's contained in a FileDocument, you should be able to wrap it in a zipinputstream, which will allow you to read the contents without resorting to a File object.
Possibly helpful for others. My code that works:
ZipInputStream zipis = new ZipInputStream(Core.getFileDocumentContent(this.getContext(), inputZip.getMendixObject()));
ZipEntry entry;
while((entry = zipis.getNextEntry()) != null) {
if (entry.isDirectory())
{
}
else
{
Core.getLogger("log").info("files to be created");
Image img = Image.create(this.getContext());
img.setName(entry.getName());
try {
Core.getLogger("log").info("retrieved filestream");
IMendixObject fileMendixObject = img.getMendixObject();
IncomingDoc id = IncomingDoc.initialize(this.getContext(), inputFile.getMendixObject());
int size;
byte[] buffer = new byte[2048];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(baos, buffer.length);
while ((size = zipis.read(buffer, 0, buffer.length))!=-1) {
bos.write(buffer, 0, size);
}
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
if (bais!=null){
Core.storeImageDocumentContent(this.getContext(), fileMendixObject, bais, 60, 60);
}
bais.close();
bos.flush();
bos.close();
} catch (ZipException ze) {
throw new MendixRuntimeException("Zipfile cannot be unzipped", ze);
}
}
}
zipis.close();
return true;