Store and retrive image from Table to file in Ax 2009 & 2012

tbltoimage

JohnkrishImageTable has two fields

1. Name

2. Image ( Container and ExtendtedDataType=Bitmap)

Insert Image

static void JohnkrishImageJob(Args _args)
{
Bindata binData = new BinData();
FilePath _path;
JohnkrishImageTable _ImageStore;

;
_path = “F:\\JKG\\Johnkrish.jpg”; // file path
binData.loadFile(_path);

// select _ImageStore where _ImageStore.Name==”John”;
_ImageStore.Image = binData.getData();
_ImageStore.doInsert();

}

Retrive Image

static void TableImageToImageFile(Args _args)
{
bindata bin = new bindata();
str content;
container image;
JohnkrishImageTable jkit;
;

select jkit where jkit.Name==”John”;
image = jkit.Image;
bin.setData(image);
// Create the base64 encoded string
content=bin.base64Encode();
info(content);
// Save it to the file system as a tif format
AifUtil::saveBase64ToFile(@”F:\test.tif”, content);

}

Advertisements

3 comments on “Store and retrive image from Table to file in Ax 2009 & 2012

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s