You can use Java actions from Community Commons to accomplish this. Try GetFileContentsFromFile. If you pass in the file name and a System.Image object, it should work.
***EDIT***
I got curious, so I tested this. This was my resources directory:
and I created this microflow
And got the image with no problems.
Yes you can. But you need some Java code. You need to adopt it with the correct module name and directory name.
Create in the resource map of your project a map and put all those images there. Then you can run this code to transform those files into Mendix image documents.
Regards,
Ronald
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
// Special characters, e.g., é, ö, à, etc. are supported in comments.
package yourmodule.actions;
import gegevensimport.proxies.yourmodule;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import com.mendix.core.Core;
import com.mendix.core.CoreException;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.systemwideinterfaces.core.UserAction;
import com.mendix.webui.CustomJavaAction;
/**
* Place your images in the resources map YourImages
*/
public class YourImagesItemImport_Cloud extends CustomJavaAction<java.lang.Boolean>
{
public YourImagesItemImport_Cloud(IContext context)
{
super(context);
}
@java.lang.Override
public java.lang.Boolean executeAction() throws Exception
{
// BEGIN USER CODE
IContext context = this.getContext();
File myDir = new File(Core.getConfiguration().getResourcesPath(),"YourImages");
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: " + myDir );
if( !file.canRead() )
throw new CoreException( "The file could not be read, the location is: " + file );
try {
FileInputStream storeStream = new FileInputStream(file);
YourImages fotoItemObject = YourImages.initialize(context, Core.instantiate(context, "yourmodule.YourImages"));
String filename = file.getName();
fotoItemObject.setName(filename);
Core.storeImageDocumentContent(context, fotoItemObject.getMendixObject(), storeStream,60 ,60);
}
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;
// END USER CODE
}
/**
* Returns a string representation of this action
*/
@java.lang.Override
public java.lang.String toString()
{
return "PortaalActieItemImport_Cloud";
}
// BEGIN EXTRA CODE
// END EXTRA CODE
}