Hello,
Looking around the internet it seems that many people struggle with using PowerApps to upload non-image files to SharePoint. Most tutorials out there show you how to do so with camera images, but this does not work for files that you pull from SharePoint.
Here's why. When PowerApps passes any file from SharePoint to Flow, it does so with a BLOB (Binary Large OBject) reference (e.g. appres://blobmanager/55de916dfa7f4640b243dbd822208afd). As far as I understand, this can't even be converted from binary since it's just a reference. Flow doesn't seem to be able to do anything with this. I could not find any way to get PowerApps to send the file in a different format - with one exception.
PowerApps does have an Add Picture control, which allows you to upload a picture from your computer. As it turns out, you can add any file with this control so long as you add it to a collection and treat it like an image (e.g. ContentBytes: UploadedImage1.Image). Shane Young's tutorial was useful for this. Below is the OnSelect code for the PowerApps button that triggers the flow that uploads the file to SharePoint:

Collections are stored as tables, and I found that I have to concatenate the ContentBytes column in PowerApps before sending it to Flow. This (mis)use of the Add Image control gets PowerApps to send the PDF's file content to Flow as a base64 file, which I then can convert using the base64ToBinary() function. I then have a Flow that is set up to receive input from PowerApps and then send the input as an email. For some reason you have to set the Flow to request input from PowerApps specifically for an email attachment. If you do this, PowerApps will send the file content as "format": "byte"; if you instead set the Flow up to request data for a Create File in SharePoint action, it will send the file content as "format": "binary" (the BLOB file reference).

So far, so so. Now I have a way to upload a file from my desktop to an Add Image control PowerApps, and I have a button that sends the file name and file content to Flow in base64. Flow then takes the file, converts to binary, and adds it to SharePoint. However, I have not found a way to do this without having to also send the file as an email attachment. If I delete the Send an Email action, I get the following error:
InvalidTemplate. Unable to process template language expressions in action 'Create_file' inputs at line '1' and column '2568': 'The template language expression 'json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$connections']['shared_sharepointonline']['connectionId']' cannot be evaluated because property 'shared_sharepointonline' doesn't exist, available properties are 'shared_office365'.
It appears that I have to keep the Send an Email action in there in order to trick PowerApps and Flow into continuing to send the file content of my PDF as a base64 file.
Does anyone have any insights as to how I can make this work without having to send an email each time a file is uploaded? My team wants to scale this solution to cover all of our SharePoint file uploads, and right now the amount of junk email generation this would imply means that it's not workable. My hope is that Microsoft will soon roll out native functionality in PowerApps so that users can upload more than just camera images to SharePoint (imagine that!).
Cheers,
rjm
Also, I noticed something very strange with the base64ToBinary() function. When I enter in into the Flow, at first it is visible. Then, as soon as I navigate away from editing the Flow, it seemingly disappears. But then if I look in the Peek Code section, it's still there! Very weird.
