StackOne File Picker

The StackOne File Picker provides a unified interface for browsing and selecting documents from third-party platforms. It abstracts provider-specific differences behind a consistent user experience and developer interface, whether the source is a file storage system (like SharePoint, OneDrive, Google Drive) or a knowledge base (like Confluence or Notion).

How It Works

The File Picker allows users to:
  • Navigate a hierarchical file tree (folders, pages, blocks)
  • Select one or more files or documents
  • Return a list of StackOne file objects, which can be used with unified operations such as GET /unified/documents/files/{id} or POST /unified/documents/files/{id}/download

Picker Types

ProviderPicker TypeNavigation ModelNotes
SharePointNativeSite → Drive → Folder → FileMicrosoft-native picker with StackOne-built site selection UI
OneDriveNativeDrive → Folder → FileStandard OneDrive picker scoped to user’s personal/business drive
Google DriveNativeDrive → Folder → FileUses Google Picker SDK
ConfluenceCustomSpace → PagePages act as both folders and files based on content/children
Notion (Coming Soon)CustomWorkspace → PagePages/blocks behave similarly to Confluence in dual file/folder roles

Output Format

When a user completes selection, the picker returns:
{
  "files": [
    {
      "id": "c28xIQaWQ6ODA5MzcyMg",
      "name": "QA text 1",
      "path": "https://exploreconfluence.atlassian.net/wiki/spaces/QS/pages/8093722/QA+text+1",
      "driveId": "7733268"
    }
  ]
}
Each fileId corresponds to a StackOne-normalized file object that can be accessed via API:
  • GET /unified/documents/files/{id} – fetch file metadata
  • POST /unified/documents/files/{id}/download – retrieve file contents (if supported)

File Object Structure (for Fetch)

When queried individually, a file returns the following structure:
{
  "id": "file_123",
  "name": "Report Q1.pdf",
  "path": "/Marketing/Reports/Q1",
  "mimeType": "application/pdf",
  "size": 204800,
  "lastModified": "2024-12-01T10:00:00Z",
  "provider": "sharepoint",
  "downloadUrl": "https://..."
}
  • For knowledge bases like Confluence and Notion:
    • Files may represent pages or blocks
    • Additional metadata like hasContent, hasChildren is provided

Developer Integration Example

  1. Trigger the Picker Use the StackOne SDK, embed directly via the UI component or trigger via the StackOne Dashboard.
  2. Receive Selection The picker will return:
    {
      "files": [
        {
          "id": "c28xIQaWQ6ODA5MzcyMg",
          "name": "QA text 1",
          "path": "https://exploreconfluence.atlassian.net/wiki/spaces/QS/pages/8093722/QA+text+1",
          "driveId": "7733268"
        }
      ]
    }
    
  3. Perform Unified Actions
    • Fetch metadata: GET /unified/documents/files/{id}
    • Download file: POST /unified/documents/files/{id}/download

Provider Feature Table

Feature / CapabilitySharePointOneDriveGoogle DriveConfluenceNotion (coming)
Picker TypeNativeNativeNativeCustomCustom
Tree Navigation
Multi-file Selection
Selectable File TypesAny documentAny documentAny documentPagesPages
Folder Navigation
Dual-role ItemsN/AN/AN/A✅ (pages)✅ (pages/blocks)
Output (on select)List of File objectsList of File objectsList of File objectsList of File objectsList of File objects
Unified Fetch / Download

Developer Integration

  1. Trigger the Picker Use the StackOne SDK, embed directly via the UI component or trigger via the StackOne Dashboard.
  2. Receive Selection The picker will return:
    {
      "files": [
        {
          "id": "c28xIQaWQ6ODA5MzcyMg",
          "name": "QA text 1",
          "path": "https://exploreconfluence.atlassian.net/wiki/spaces/QS/pages/8093722/QA+text+1",
          "driveId": "7733268"
        }
      ]
    }
    
  3. Perform Unified Actions
    • Fetch metadata: GET /unified/documents/files/{id}
    • Download file: POST /unified/documents/files/{id}/download

Auth & Permissions

  • Each provider uses OAuth2 authentication via StackOne’s integration flow
  • File access scopes are handled per provider during auth
    • SharePoint: Files.Read.All, Sites.Read.All
    • Google Drive: https://www.googleapis.com/auth/drive.readonly
    • Confluence/Notion: Read access to spaces/pages/blocks

StackOne File Picker SDK Documentation

The StackOne File Picker SDK enables you to integrate file selection from connected accounts into your application. Below are the installation steps, usage examples, and API details.

Installation

Install the SDK using one of the following package managers:
# Using NPM
npm install --save @stackone/file-picker

# Using Yarn
yarn add @stackone/file-picker

Connect Session Token

The File Picker requires creating a separate connect session token with the Account ID and Provider Key of a connected account.

Usage

Below you can find the basic usage of the StackOne File Picker SDK using React:
import React, { useState, useEffect, useCallback } from 'react';
import { FilePicker } from '@stackone/file-picker';
import { StackOne } from "@stackone/stackone-client-ts";

const _stackOne = new StackOne({
  security: {
    password: "",
    username: "",
  },
});

export const FilePickerButton = () => {
  const [filePicker, setFilePicker] = useState(null);

  useEffect(() => {
    const initializePicker = async () => {
      const { sessionToken } = await _stackOne.connectSessions.createConnectSession({
        categories: [ConnectSessionCreateCategories.Documents],
        accountId: '{{Connected Account ID}}',
        provider: '{{Provider Key}}',
        ...
      });
      setFilePicker(new FilePicker({ sessionToken }));
    };

    initializePicker();
  }, []);

  const handleClick = useCallback(() => {
    filePicker?.open();
  }, [filePicker]);

  return (
    <button onClick={handleClick} disabled={!filePicker}>
      Open File Picker
    </button>
  );
};

API Reference

File Picker Configuration Options

const filePicker = new FilePicker({
  sessionToken: 'your-session-token', // Required
  containerId: 'file-picker-container', // Optional: DOM container ID
  baseUrl: 'https://app.stackone.com', // Optional: API instance
  fields: ['name', 'path', 'driveId'], // Optional: which file fields to return
  showBranding: false, // Optional: show StackOne footer (default: true)
  folderSelectionEnabled: true, // Optional: allow folder selection (default: false)
  driveSelectionEnabled: true, // Optional: allow drive selection (default: false)

  // Callback Events
  onFilesPicked: (files) => {
    console.log('Selected files:', files);
    // Process selected files for indexing
  },
  onOpen: () => {
    console.log('File picker opened');
  },
  onClose: () => {
    console.log('File picker closed');
  },
  onCancel: () => {
    console.log('File selection canceled');
  },
  onError: (error) => {
    console.log('File picker error:', error);
  }
});

File Selection Response Format

When users complete their selection, the onFilesPicked callback receives different response formats depending on what was selected:
// Example response when only files are selected
{
  "files": [
    {
      "id": "c28xIQaWQ6ODA5MzcyMg", // Unified file ID
      "name": "Project Proposal.pdf", // File name
      "path": "/Projects/2024/Project Proposal.pdf", // File path
      "driveId": "7733268" // Drive identifier
    },
    {
      "id": "d39yJRbXR7PEB6NzY3Ng",
      "name": "Budget Analysis.xlsx",
      "path": "/Projects/2024/Budget Analysis.xlsx",
      "driveId": "7733268"
    }
  ]
}
Folder Selection Handling: When folderSelectionEnabled: true is set, users can select entire folders. The response will include folder IDs in the selection. To retrieve all files within selected folders (including nested subfolders), use the List Files API with the folder_id parameter and nested_files: true option to automatically fetch all nested content.
Note: Only onFilesPicked is typically required for document management use cases. Other callbacks (onOpen, onClose, onCancel, onError) are optional and depend on specific user actions or error conditions.

Picker Output Format

When users complete their selection, the picker returns different formats based on what was selected and configured:
{
  "files": [
    {
      "id": "c28xIQaWQ6ODA5MzcyMg",
      "name": "Project Proposal.pdf",
      "path": "/Projects/2024/Project Proposal.pdf",
      "driveId": "7733268",
      "mimeType": "application/pdf",
      "size": 2048000,
      "lastModified": "2024-01-15T10:30:00Z"
    }
  ]
}

FilePicker Methods

open()
method
Opens the file picker interface.
close()
method
Closes the file picker interface.

Coming Soon: Notion Support

StackOne will soon launch a custom picker for Notion, modeled similarly to Confluence:
  • Block/page navigation
  • Unified selection of document-style pages
  • Multi-select and metadata retrieval