private void daxErp_conImageExample()
{
#define.jpeg('.jpg')
#define.openMode("R")
Dialog dialog;
DialogField dialogFileName;
FileIoPermission perm;
FilePath filePath;
FileName fileExt;
FileName fileName;
Filename fileNameWithPath;
Bindata daxRead, daxSave;
container readPic;
str daxBase64;
;
dialog = new Dialog("DAX ERP TRAINING Example - Read, Save and Write Image to and from the container");
dialog.addGroup("Picture file upload");
dialogFileName = dialog.addField("fileNameOpen", "Select JPEG image file to import");
dialog.run();
if (dialog.run())
{
fileNameWithPath = dialogFileName.value();
if(!fileNameWithPath)
throw error("Filename must be filled");
[filePath, fileName, fileExt] = fileNameSplit(fileNameWithPath);
if (fileExt != #JPEG)
throw error(strFmt("The extension %1 is not allowed.The correct extension should be %2.", fileext, #JPEG));
perm = new FileIoPermission(fileNameWithPath, #openMode);
if (perm == null)
{
throw error("No rights to perform this action");
}
perm.assert();
daxRead = new BinData();
daxSave = new BinData();
if (daxRead.loadFile(fileNameWithPath))
{
// Reading and storing image into the container
readPic = daxRead.getData();
}
CodeAccessPermission::revertAssert();
// Writing the image to a file from the container
daxSave.setData(readPic);
daxBase64 = daxSave.base64Encode();
AifUtil::saveBase64ToFile(@"D:\\imageOutput.jpeg", daxBase64);//Saving at destination //folder change your own path other wise you ill get error "Object //'CLRObject' could not be created"
}
}
when you executed u ill get this dialogbox

select path and save in your system which given path in code
Note : change the destination Path to avoid to get the error as "Object //'CLRObject' could not be created"

{
#define.jpeg('.jpg')
#define.openMode("R")
Dialog dialog;
DialogField dialogFileName;
FileIoPermission perm;
FilePath filePath;
FileName fileExt;
FileName fileName;
Filename fileNameWithPath;
Bindata daxRead, daxSave;
container readPic;
str daxBase64;
;
dialog = new Dialog("DAX ERP TRAINING Example - Read, Save and Write Image to and from the container");
dialog.addGroup("Picture file upload");
dialogFileName = dialog.addField("fileNameOpen", "Select JPEG image file to import");
dialog.run();
if (dialog.run())
{
fileNameWithPath = dialogFileName.value();
if(!fileNameWithPath)
throw error("Filename must be filled");
[filePath, fileName, fileExt] = fileNameSplit(fileNameWithPath);
if (fileExt != #JPEG)
throw error(strFmt("The extension %1 is not allowed.The correct extension should be %2.", fileext, #JPEG));
perm = new FileIoPermission(fileNameWithPath, #openMode);
if (perm == null)
{
throw error("No rights to perform this action");
}
perm.assert();
daxRead = new BinData();
daxSave = new BinData();
if (daxRead.loadFile(fileNameWithPath))
{
// Reading and storing image into the container
readPic = daxRead.getData();
}
CodeAccessPermission::revertAssert();
// Writing the image to a file from the container
daxSave.setData(readPic);
daxBase64 = daxSave.base64Encode();
AifUtil::saveBase64ToFile(@"D:\\imageOutput.jpeg", daxBase64);//Saving at destination //folder change your own path other wise you ill get error "Object //'CLRObject' could not be created"
}
}
when you executed u ill get this dialogbox
select path and save in your system which given path in code
Note : change the destination Path to avoid to get the error as "Object //'CLRObject' could not be created"
have you ever tried uploading the product images??
ReplyDelete