Mime type warnings with java import of images

0
In our model we can do a bulk import of pictures. The import goes as expected but in the console I get 'Could not find mime type for file 'xyz'. Uploading the exact same image manually this warning goes away. But how do I influance in Java how Mendix handles the mime type? This is the Java code we use to import the images: IContext context = this.getContext(); File myDir = new File(this.pad); if( myDir.exists() && myDir.isDirectory()) { File[] files = myDir.listFiles(); for(int i=0; i < files.length; i++) { File file = files[i]; if( !file.exists() ) throw new CoreException( "No file exists at location: " + this.pad ); if( !file.canRead() ) throw new CoreException( "The file could not be read, the location is: " + file ); try { FileInputStream storeStream = new FileInputStream(file); Foto fotoItemObject = Foto.initialize(context, Core.instantiate(context, "GegevensImport.Foto")); fotoItemObject.setNaam(file.getName()); Core.storeFileDocumentContent(context, fotoItemObject.getMendixObject(), file.getName(), storeStream); } catch( FileNotFoundException e ) { throw new CoreException( "The file could not be stored because something went wrong while reading the file, the location was: " + file, e ); } } } return true; Regards, Ronald
asked
2 answers
0

I don't know where the difference comes from, are you sure the file.getName() call actually results in something valid? Though it shouldn't really matter, the mime type is simply the file extension, it won't affect anything else.

Edit: Oh I just re-read your question, this is explicitly about a file called 'xyz'? Then it makes sense, there is no file extension, thus no mime type.

By the way, you may want to use the Core.storeImageDocumentContent method instead if you want to be able to generate thumbnails etc.

answered
0

You're giving the file the extension .Foto, that's not an official mime type so it won't be recognized. Not that it really matters, it just means browsers won't be able to open it without explicitly telling them that it's an image.

answered