Issue Summary
When using the file_picker package on the Web platform, selecting an image from a OneDrive folder results in a FilePickerResult containing a PlatformFile object with bytes set to null. This makes it impossible to access the content of the selected file for further use, such as displaying the image.
Steps to Reproduce
Use the FilePicker.platform.pickFiles method on the web platform (e.g., Chrome).
Select an image from the OneDrive folder.
Observe that the returned PlatformFile contains metadata (name, size) but has bytes and readStream as null.
Sample Code:
final result = await FilePicker.platform.pickFiles(
allowMultiple: false,
type: FileType.custom,
allowedExtensions:
<String>[
'jpg',
'png',
],
);
if (result != null) {
print(result.files.first.bytes); // Outputs: null
}
Observed Behavior
The PlatformFile object returned has the following structure:
PlatformFile(name: logo.png, bytes: null, readStream: null, size: 388400)
Both bytes and readStream are null, making it impossible to use the file's content.
Expected Behavior
The PlatformFile.bytes field should contain the file's content as a byte array when selecting a file from the OneDrive folder, as it does for other folders.
Additional Details
Version Used:
Issue persists on both 8.0.0+1 and the latest version, 8.1.4.
Reproducibility:
Tested on Chrome browser on both MacOS and Windows platforms.
Attempts to Resolve:
Adding withData: kIsWeb to the pickFiles call did not resolve the issue.
Testing in Example Project:
Cloned the example project from GitHub repository.
Added the following code to reveal the issue clearly:
return ListTile(
title: Text(name),
subtitle: Text(path ?? 'bytes: ${_paths?.firstOrNull?.bytes}'), // <<< added this, because on web `path` is null.
);
Confirmed that the bytes field is null for files selected from the OneDrive folder.
Notes
The README shows an example for Windows where files from OneDrive are selected successfully, suggesting this behavior is unexpected.
Issue Summary When using the
file_picker
package on the Web platform, selecting an image from a OneDrive folder results in aFilePickerResult
containing aPlatformFile
object with bytes set tonull
. This makes it impossible to access the content of the selected file for further use, such as displaying the image.Steps to Reproduce Use the
FilePicker.platform.pickFiles
method on the web platform (e.g., Chrome). Select an image from the OneDrive folder. Observe that the returnedPlatformFile
contains metadata (name
,size
) but hasbytes
andreadStream
asnull
. Sample Code:Observed Behavior The
PlatformFile
object returned has the following structure:PlatformFile(name: logo.png, bytes: null, readStream: null, size: 388400)
Bothbytes
andreadStream
are null, making it impossible to use the file's content. Expected Behavior ThePlatformFile.bytes
field should contain the file's content as a byte array when selecting a file from the OneDrive folder, as it does for other folders.Additional Details
Issue persists on both 8.0.0+1 and the latest version, 8.1.4.
Tested on Chrome browser on both MacOS and Windows platforms.
withData: kIsWeb
to thepickFiles
call did not resolve the issue.Confirmed that the
bytes
field is null for files selected from the OneDrive folder. Notes The README shows an example for Windows where files from OneDrive are selected successfully, suggesting this behavior is unexpected.https://github.com/user-attachments/assets/2360835a-0bf2-4345-bb6f-b8e0e5034917