5 min readUpdated Mar 2, 2026

OneDrivePicker Documentation

Overview

The OneDrivePicker component is a custom file browser that allows users to select files from their OneDrive. It leverages the backend API to fetch and display files within a folder-browsing user interface. The component is designed to resemble the Google Drive picker, offering a familiar experience for users transitioning between platforms. It supports single or multiple file selections and enables filtered browsing based on specified file types.

Purpose

The primary purpose of the OneDrivePicker is to facilitate easy and efficient file selection for applications that require data uploads or integrations with OneDrive. By implementing this component, users can access their stored files while providing capabilities tailored to specific use cases, such as data analysis or project management.

Settings

The OneDrivePicker component includes several settings that customize its functionality and appearance. Below are detailed explanations for each setting:

1. value

2. onChange

3. fileType

4. label

5. description

6. multiSelect

How It Works

  1. Initialization: The component initializes state variables for loading status, error state, open status, current folder id, folder history stack, loaded files, selected files, and search input.

  2. File Fetching: When the component is opened or the current folder changes, the fetchFiles function is triggered, sending an API request to retrieve files from OneDrive based on the set folder ID. The results are then filtered according to the specified fileType.

  3. Folder Navigation: Users can navigate through folders via clickable elements that alter the current folder ID. The state of folder history is maintained to facilitate backtracking.

  4. File Selection: Users can select or deselect files based on the multiSelect setting. The selection modifies the selectedFiles state.

  5. Confirmation and Cancellation: Upon confirming selection through the confirm button, the selected files are passed via the onChange callback. The state resets upon cancellation.

  6. Search Functionality: Users can filter displayed files using a search input box, enabling quick access to files by name.

Data Expectations

The OneDrivePicker expects the following data format for value:

If a single file is selected, an object in the same format is provided.

Use Cases & Examples

Use Cases

  1. Data Analysis Applications: Users may need to upload datasets from their OneDrive for analysis. The OneDrivePicker can help users quickly find and select relevant files.

  2. Report Generation Tools: A reporting application can leverage the component to allow users to select reports saved in OneDrive, streamlining the process of gathering necessary documents.

  3. Content Management Systems (CMS): A CMS can integrate the OneDrivePicker to let users select images or documents from their OneDrive account for use in content creation or editing.

Example Configuration

Use Case: Allow users to select multiple datasets for analysis in a Data Analysis Application.

Configuration:

javascript
<OneDrivePicker
    value={selectedFiles} // Assuming selectedFiles is managed in the parent component's state
    onChange={(files) => {
        // Handle the selected files here, e.g., pass them to an analysis function
        console.log("Selected Files:", files);
    }}
    fileType="dataset" // Specify that users should select dataset files
    label="Choose Your Dataset Files"
    description="Please select one or more CSV, JSON, or Excel files."
    multiSelect={true}
/>

In this example, the OneDrivePicker is configured to prompt users to select dataset files, allowing for multiple selections and providing clear labels and descriptions to guide the user experience.