Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Export Image from a Table field to a local directory

Posted on by 36
Hi,
 
I want to export the image saved in a table for example CompanyImage and I want to export the Image from Companyimage to a local directory on my system. I followed the following link: https://eprogrammers.blogspot.com/2016/07/how-to-export-import-images-or-pictures.html
 
Kindly see the code below that I wrote.
 
 
I am getting an error in AifUtil::saveBase64ToFile(@filepath, content) that this method does not exist in this class. It is true that this method does not exist in this class but every guide article mentions only this way to export images. The other way I tried is as follows:
 
 
It is also not working as no file is saving in the directory. Any quick solutions by the community are appreciated. Thanks!
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,240 Super User 2024 Season 2 on at
    Export Image from a Table field to a local directory
    Hi Sadia,
     
    You can use the next coding for retrieving the file into a stream and send it to the user for download.
     
    public void downloadImage()
    {
        System.IO.Stream stream = null;
        container        fileContainer = myTable.Image;
    
        if (fileContainer && conLen(fileContainer > 0)
        {
            Binary binaryData = Binary::constructFromContainer(fileContainer);
            if (binaryData)
            {
                stream = binaryData.getMemoryStream();
            }
    
            File::SendFileToUser(stream, 'image.tiff');
        }
    }
     
  • SA-20091232-0 Profile Picture
    SA-20091232-0 36 on at
    Export Image from a Table field to a local directory
    Hi Andre,
    The image stored in the table in D365Fo is already in .tiff format in a container-type field. I just want to export it through code, like we export any table data of D365FO in an Excel sheet through code i.e. Like this https://community.dynamics.com/forums/thread/details/?threadid=60d59b32-171a-451a-b297-111fb4caf732. But the difference is that I want to export only image from the table and in image format instead of excel or CSV. In short, I want to download the image from the table through code. So Let's forget for once to export it to either local storage or any other cloud platform. can we download the image from the D365Fo table?
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,240 Super User 2024 Season 2 on at
    Export Image from a Table field to a local directory
    Hi Sadia,
     
    Is the image you have in your environment already in a tiff format? As mentioned in my previous reply, the Dynamics 365 application can't access your local storage. You would then need to use middleware that can retrieve the exported image from a cloud storage or stream and move it to your local drive.
  • SA-20091232-0 Profile Picture
    SA-20091232-0 36 on at
    Export Image from a Table field to a local directory
    Hi Andre,
     
    I'm using D365FO and I want to export the image in .tiff format on my local directory. How can I achieve that through data entities? As far as I know, data entities cannot export data in image format. Can you advise any solution based on the export of images from a table field on the local directory? 
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,240 Super User 2024 Season 2 on at
    Export Image from a Table field to a local directory
    Hi Sadia,
     
    Are you using Dynamics AX 2012 or Dynamics 365 F&O? The method doesn't exist in Dynamics 365 as that became a cloud solution which is not aware of your local device.
    In Dynamics 365, you can use Data Entities and export via Data Management, or create a stream giving the option to the user to download a file.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans