cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rajesh
Advocate II
Advocate II

PCF for attachments upload - Uploading large file throws error

Hi
 
I'm working on a canvas PowerApps dashboard to allow users to upload files to a Azure file storage. Users should have the ability to select multiple files. The no. of files to be uploaded is quite large, could be in hundreds. The file size is also quite high, could be upto 250MB.
 
PowerApps does not have a native file attachment control. We tried using the SharePoint file attachment control as shown in this link (https://officepoweruser.com/upload-a-file-to-sharepoint-in-power-apps/ ), however this has severe limitations. It doesn't allow multiple file select, max. file size is only 10MB.
 
I've tried creating a custom PCF component which uses native Device API as shown below.

 

private onUploadButtonClick(event: Event): void 
		{	
			var fileOptions = {} as ComponentFramework.DeviceApi.PickFileOptions; 
			fileOptions.allowMultipleFiles = true;
			fileOptions.maximumAllowedFileSize = 104857600;
			this._context.device.pickFile(fileOptions).then(this.processFile.bind(this), this.showError.bind(this));
		}

private processFile(files: ComponentFramework.FileObject[]): void
		{
			if(files.length > 0)
			{
				let fileList = "";
				try{
					files.forEach(element => {
						fileList += element.fileName;
						fileList += "#";
						fileList += element.fileContent;
						fileList += ";";
					});
					this._value = fileList;
					this._notifyOutputChanged();
				}
				catch(err)
				{
					this.showError();
				}
			}
		}
	
public getOutputs(): IOutputs
		{
			// return outputs
			let result: IOutputs = 
				{
					value: this._value!
				};
			
				return result;
		}

<property name="value" display-name-key="value_Display_Key" description-key="value_Desc_Key" of-type="Multiple" usage="bound" required="true" />

 

 

In the processFile callback, I'm looping through the list of files selected, concatenating the base64 file content and returning that as output. Though I've set the max. allowed size is 100MB, I get an error when I try to upload a 80MB file. The max. size I could upload was about 70MB

 

It is not clear from Device API documentation if it's a known limitation - https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/device/pickfile
 
However the return data type that I'm using is "multiple" seems to suggest the value can only contain up to 1,048,576 text characters. Not sure if the issue is caused by this
 
Any suggestion on how to fix the size issue? Also any suggestion to build a scalable upload component in PowerApps?
 
Thanks
1 ACCEPTED SOLUTION

Accepted Solutions

@v-xida-msft  I've managed to solve this by calling the Azure javascript library for file upload from within the component. With this approach I'm able to upload very large files and multiple file uploads. I've tried uploading 500 MB file and seemed to work fine. Component now sends only the list of files uploaded back to the host, so I never run into the issue of string limitation.

View solution in original post

5 REPLIES 5
v-xida-msft
Community Support
Community Support

Hi @Rajesh ,

Based on the Client API that you mentioned, I think you are in right direction. The context.device.pickFile(options) Client API could opens a dialog box to select files from your computer (web client) or mobile device (mobile client), but this API is only available in Model-Driven app rather than canvas app.

 

According to the issue that you mentioned, I think this issue is related to the data type of the "value" property you set in your PCF project. When you assign value to the "value" (Multiple type) property, it could not be more than the known limit --  1,048,576 text characters.

 

Based on the needs that you mentioned, I afraid that the "Multiple" data type could not achieve your needs, and there is no way to achieve your needs using PCF due to this known limit.

 

If you would like this feature to be improved in PowerApps, please consider submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

 

If you would like to get further help in this issue, please consider submit an assisted support ticket through the following link:

https://powerapps.microsoft.com/en-us/support/pro

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-xida-msft  I've managed to solve this by calling the Azure javascript library for file upload from within the component. With this approach I'm able to upload very large files and multiple file uploads. I've tried uploading 500 MB file and seemed to work fine. Component now sends only the list of files uploaded back to the host, so I never run into the issue of string limitation.

View solution in original post

Hi @Rajesh ,

Have you solved your problem?

 

If you have solved your problem, please consider go ahead to click "Accept as Solution" to identify this thread has been solved

 

If you do not mind, you could consider share your solution here, so any other users faced same issue could refer to your solution.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MarinaPA
Helper I
Helper I

Hi,

is there any solution for large file upload? I also need to upload large files with powerapps control in sharepoint list or library, the limit is still10MB, can this be increased? 

Thank you 

msuser
Frequent Visitor

Hi, @Rajesh   i have a similar requirement please let me know if it is possible to share the final code or if possible please share the PCF component zip file through Github, 

thank you.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,979)