cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tludwig
Advocate I
Advocate I

PDF Corrupted in Sharepoint

I created a flow to grab a PDF attachment from an email when one arrives and save it in a Sharepoint document library. The file is created correctly but it cannot be previewed or opened in Adobe Acrobat. The attachments can be opened just fine when I open them through the email. When I try to open it in Adobe, it gives this error:

Capture.PNG

 

Here are screenshots of my flow. I omitted the middle section but it is just variable manipulation and shouldn't have any impact on the file content. Any help is appreciated!

Capture1.PNG

Capture2.PNG

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @tludwig 

 

Did you try to use the same filename when you create via Flow? 

 

The test reveals that you have some specific content which is inside the PDF doc. Look the content whether its mapping anything specific. How it gets generated compared to other PDF docs?

 

Thanks

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

13 REPLIES 13
abm
Super User
Super User

Hi @tludwig 

 

I tested this and it is working as expected for me.

 

image.png

 

Please make sure you have another loop above the attachments loop. I couldn't see that from your screenshot you provided.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
chsanche
Community Support
Community Support

Hi @tludwig 

I tried to reproduce this in my environment but it seems to be working fine. I created a simplified version of the flow:

Annotation 2020-04-17 173027.png

Can you please remove the variables from the create file action to test and let me know the result?

If this post helps you give a :thumbs_up: and if it solved your issue consider Accept it as the solution
ScottShearer
Super User
Super User

@tludwig 

As a test, can you saving the file from Outlook directly to the SharePoint library or download/upload the file to the library.

Try to open it from SharePoint and see if you experience the same issue.  The reason is to determine if the issue is with your Flow or with your workstation or the SharePoint library.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

Hi @tludwig 

 

Can you also check if the email has an attachment of type pdf only. Note that images in the body of the email or the signatures containing images area also pulled along with attachments and those might be the issue as well. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Thanks for your help everyone. @abm @chsanche @yashag2255 @ScottShearer 

 

I tested with a different PDF and after running it through the flow, it could be opened in Sharepoint so it is an issue specific to the PDF I'm using. I then uploaded the "broken" PDF directly into the Sharepoint library and it could be opened just fine. So the PDF is fine as is but somehow gets corrupted when it is run through the flow. Any ideas?

 

Maybe these screenshots of the Create File action when I run the flow with the corrupted PDF will help?

createfile1.PNG

createfile2.PNG

Hi @tludwig 

 

For some reason the attachment type is getting converted to octet stream. Can you try wrapping the content in the base64 function and try again. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

abm
Super User
Super User

Hi @tludwig 

 

Another thought related to upload. Try uploading the file to OneDrive or FileSystem and see if that works or not? This will give some indication where the problem is only for SharePoint or the PDF file.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Thanks @abm 

 

I switched out the Sharepoint Create File action for a Onedrive for Business Create File action and I still have the same problem--the PDF I need to use is corrupted after being run through the flow and a different PDF that I tested works fine. Any other suggestions? Thanks

Thanks @yashag2255 

 

Both the "corrupted" PDF and my other test PDF that works fine are being converted to "octet-stream" according the input data in the Create File action. If you think wrapping the content in the base64 function may still be the solution, I will give it a try. I will need some clarity on how to do that though. Thanks

Hi @tludwig 

 

Did you try to use the same filename when you create via Flow? 

 

The test reveals that you have some specific content which is inside the PDF doc. Look the content whether its mapping anything specific. How it gets generated compared to other PDF docs?

 

Thanks

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

@abm I changed the file name from my custom name to the original file name using dynamic content and this time it created 3 files at once in Sharepoint--the PDF (which can now be opened!) and two images which were part of the signatures in the test email I was forwarding.

 

I deleted the signatures in the test email and tried again with my custom file name and the images are no longer created and the PDF can be opened now.

 

I guess if you're unknowingly capturing multiple attachments at once, you won't know it unless you keep all dynamic content the same in the Create File action. 

Hi @tludwig 

 

Thanks for the update. Glad that you found the issue. The signature file names are fixed so you could check that in an IF condition to exclude those.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
ZERAREZ
Frequent Visitor

Hi,

 

I believe I am encountering the same issue; however, in all file types. 

 

My initial goal is to simply upload copies of all email attachments to a specific SharePoint Document Library. I was able to do that but the files being created automatically are all corrupted/non-functional and 4 bytes in size.

 

ZERAREZ_0-1633720712012.png

ZERAREZ_1-1633720726088.png

 

I have tried a work around re: base64ToBinary(items('Apply_to_each')?['contentBytes']); however, it's giving me a 'Null' error. I'm not sure where to go from here after searching the web for possible fixes and failing.

 

ZERAREZ_2-1633720883228.png

 

Appreciate any help,

 

Neil

 

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events happening this month - don't miss out!

 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (5,132)