Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilePicker on Web: Null bytes for Files Selected from OneDrive Folder #1631

Open
Turskyi opened this issue Nov 18, 2024 · 1 comment
Open
Labels
new issue An issue that hasn't yet been seen from the maintainer stale

Comments

@Turskyi
Copy link

Turskyi commented Nov 18, 2024

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:
  1. Adding withData: kIsWeb to the pickFiles call did not resolve the issue.
  2. 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.

Screen.Recording.2024-11-18.at.4.32.29.PM.mov
@Turskyi Turskyi added the new issue An issue that hasn't yet been seen from the maintainer label Nov 18, 2024
Copy link

This issue is stale because it has been open for 7 days with no activity.

@github-actions github-actions bot added the stale label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new issue An issue that hasn't yet been seen from the maintainer stale
Projects
None yet
Development

No branches or pull requests

1 participant