web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create file action in ...
Power Automate
Unanswered

Create file action in Sharepoint yields unreadable png file

(1) ShareShare
ReportReport
Posted on by 10
NOTE: Please see the post I made regarding this on May 2nd 2025.    The Sharepoint location that I was trying to write the .png image to is actually a Teams Channel Document folder.   I tried it with an actual Sharepoint site and it all works.
Why is teams so different, since the backend for Teams is SHAREPOINT.   Any help would be appreciated as the site I need to post the image to is a Teams Site.
 
 
 
So this is a little bit complicated to explain, but i'll try...   All of this is running in a Cloud Flow. 
 
I have an excel workbook that ingests a csv file everyday, and then updates chart data on a "dashboard" page on the last worksheet.   There is an Excel Office script that runs to produce this.   This part runs perfectly when the whole process is on OneDrive or on Sharepoint ( Actually a Teams Site).   
 
The flow then runs another Excel Office Script to get the dashboard page as an image and writes it to .PNG file in Onedrive, or ( if I could ever get it to work ) in a Sharepoint library.   The issue I have is that both scripts run fine, but while the file written to Onedrive is a valid .png image file... using the same commands to write this file to Sharepoint creates a .png file that is NOT in the correct .png format.
 
I isolated the steps to reproduce the back end part of this flow to test with.   I have the Excel Workbook in the Sharepoint library and can execute the "Run Script" command perfectly fine.  The script will return a variable called "base64Img" which contains the image of the dashboard page from Excel. 
 
I then have 2 - Create File actions after this.   
 
The create file actions both use an Expression of  " dataUriToBinary(outputs('Run_script')?['body/result/base64Img']) "  where they are using the output of the Run Script step.  Identically.  
 
The first is to try to write the file to the Sharepoint directory.... the file gets created but is not in a readable .png format...   
 
The second uses a OneDrive Create file action with the same expression for file content, and this one produces a perfectly formed and readable .png file. 
Here is the flow...
 
I really need to get this whole process working in the Sharepoint environment, as this is something that many others in the IT Department might need to be able to work on, or mimic for other needs and I don't want it to be tied to my own OneDrive account. 
 
I when looking at the "downloaded" input from the steps... the first part of the OneDrive step looks like this:  ( just a top snippet of the data)  ( This is the downloaded INPUT not the downloaded OUTPUT... they should be the same)
*************************************
{
  "host": {
    "apiId": "subscriptions/e9bc7b8d-bb95-4e7a-baf8-230462d93177/providers/Microsoft.Web/locations/westus/runtimes/msmanaged-na/apis/onedriveforbusiness",
    "connectionReferenceName": "shared_onedriveforbusiness",
    "operationId": "CreateFile"
  },
  "parameters": {
    "folderPath": "/Documents/NetworkUptime/RawData",
    "name": "NetWORKUptime.png",
    "body": {
      "$content-type": "image/png",
      "$content": "iVBORw0KGgoAAAANSUhEUgAACLcAAAisCAYAAACwU5LlAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAP+lSURBVHhe7P1/6CXXeef75jKeE8HxYexzdbiCo4DA/kN3ri7kgGD8hxhywGAN+A9xxsYaYoxDjLEmwiSDCIqOuCbYg5DtHIFNRiLB42DjNFgEzVEiy7IS/6BjW7GOLZmOpaNudbekltSSuq3W75bVatWtz3c9Za1e/dSqWruq9q7a+/2CD1Lvvdf+Ubt2Pftb69lVvwEAAABgvioAAAAAg9nXawAAAAAAAAAAMDbbFw8AAABgAPt6DQAAAAAAAAAAxmb74gEAAAAMYF+vAQAAAAAAAADA2GxfPAAAAIAB7Os1AAAAAAAAAAAYm+2LBwAAADCAfb0GAAAAAAAAAABjs33xAAAAAAawr9cAAAAAAAAAAGBsti8eAAAAwAD29RoAAAAAAAAAAIzN9sUDAAAAGMC+XgMAAAAAAAAAgLHZvngAAAAAA9jXawAAAAAAAAAAMDbbFw8AAABgAPt6DQAAAAAAAAAAxmb74gEAAAAMYF+vAQAAAAAAAADA2GxfPAAAAIAB7Os1AAAAAAAAAAAYm+2LBwAAADCAfb0GAAAAAAAAAABjs33xAAAAAAawr9cAAAAAAAAAAGBsti8eAAAAwAD29RoAAAAAAAAAAIzN9sUDAAAAGMC+XgMAAAAAAAAAgLHZvngAAAAAA9jXawAAAAAAAAAAMDbbFw8AAABgAPt6DQAAAAAAAAAAxmb74gEAAAAMYF+vAQAAAAAAAADA2GxfPAAAAIAB7Os1AAAAAAAAAAAYm+2LX4Sbb75ZkwZu3v3ud1cnT560W/bn3Zeyf/9+uwUQfOADH3DXFV2+blo/veeilD6f3OdK122bBx98sLr88st//Rq17djG1zl3d911V3XDDTfsra96D+L1Tv/W5bpet0M31b+PfOQj5yzHa665ZqW6ODfb/Nq
*********************************************
 
While the downloaded input from the Sharepoint action looks like this:   (again, only a snippet of the top) .... it almost looks like this is already in PNG format, but I have tried all sorts of different ways to account for this but cannot. 
******************************************
{
"host": {
"apiId": "subscriptions/e9bc7b8d-bb95-4e7a-baf8-230462d93177/providers/Microsoft.Web/locations/westus/runtimes/msmanaged-na/apis/sharepointonline",
"connectionReferenceName": "shared_sharepointonline",
"operationId": "CreateFile"
},
"parameters": {
"dataset": "https://csgroup1.sharepoint.com/sites/DASafetyCommittee",
"folderPath": "/Shared Documents/General/NetworkUptime/RawData",
"name": "RobsNetworkUptimes.png",
    "body": "�PNG\r\n\u001A\n\u0000\u0000\u0000\rIHDR\u0000\u0000\b�\u0000\u0000\b�
\b\u0006\u0000\u0000\u0000�S��\u0000\u0000\u0000\u0001sRGB\u0000��\u001C�\u0000\u0000\u0000\u0004gAMA\u0000\u0000��\u000B�a\u0005\u0000\u0000\u0000\tpHYs\u0000\u0000\u000E�\u0000\u0000\u000E�\u0001�o�d\u0000\u0000��IDATx^���%�y���2�\u0013��a�su������Cw�.�`��\u0018r�`\r�\u000Fq��\u001Ab�C��&�$�\b���&؃��\u001C�MF\"��`�4X\u0004�Q\"˲\u0012��c[��-����nu���Ԓ�����jխ�w=e�^�ԪZ��������\u000FR���Q�v=�[��U�\u0001\u0000\u0000\u0000`�*\u0000\u0000\u0000\u0000���k\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u000006�\u0017\u000F\u0000\u0000\u0000`\u0000�z\r\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000�f�
************************************
 
I just don't get why the Sharepoint Create file looks at this so differently than the OneDrive action.   Onedrive is actuall built on Sharepoint, so it makes no sense.
 
Any help would be greatly appreciated...
Categories:
I have the same question (0)
  • MichaelFP Profile Picture
    1,847 Super User 2025 Season 2 on at
    Try to use the expression on the compose action, and after that use in sharepoint action "create file".  Maybe it's not able to handle as binary.
     
    If my answer helped you, please give me a thumbs up (👍). If solve your question please mark as answer ✔️. This is help the community.
     
     
  • collabSolutions Profile Picture
    10 on at
    Thanks for the suggestion @MichaelFP I had tried many combinations of using a Compose in between.  To be sure, I did it again at your suggestion using a DataURIT0Binary() expression on the output of the script as well as DataURIToString() and neither of these work. 
     
    It just will not format the file content properly when using this on SharePoint vs OneDrive.  
     
    Steps should be identical except of course for the location of where the data is being written to.    
  • collabSolutions Profile Picture
    10 on at
    Been a while as I had to move forward by creating this project in my own OneDrive.    BUT... I'm looking into this once again and today discovered that this issue is NOT with Sharepoint exactly as if I write to an actual SharePoint site it does work...
     
    But the problem here is that I'm actually trying to write this data to a Teams Channel Document folder!   If the folder is part of a teams site, the resulting files will all be unreadable .png files, but if the folder is part of a sharepoint site... then all is okay.
     
    I can only use the Sharepoint  Connector in Power Automate as there is not a "create file in teams" action, only a create file in Sharepoint.    The issue is that the PowerAutomate Flow WILL create a file and the flow will run, but the image is not in a readable format.    Again, if I change the output site and directory to be an actual sharepoint site, the flow runs and the file IS readable.
     
    Can anyone explain why when this sharepoint location is actually part of a Teams Site, this process can't correctly create a file.  I really can't understand this.    So disappointing.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard