2.7 KiB
2.7 KiB
SharePoint Browser
A modern Python-based file browser for Microsoft SharePoint, specifically designed to bypass the Windows MAX_PATH (260 character) limitation. It achieves this by interacting directly with the Microsoft Graph API using unique IDs and downloading files to short, temporary local paths for editing.
Project Overview
- Purpose: Provide a seamless SharePoint browsing and editing experience regardless of folder depth.
- Key Strategy: Uses unique Microsoft Graph API IDs instead of traditional file paths to avoid path length issues.
- Core Workflow:
- Authenticate via MSAL.
- Browse SharePoint sites/folders dynamically.
- Checkout a file on SharePoint.
- Download to a short local path (e.g.,
C:\Temp_SP\[ShortHash].[ext]). - Monitor local file usage; detect when the editing application is closed.
- Upload the modified file back to SharePoint.
- Checkin and clean up local temporary files.
Tech Stack
- Language: Python 3.x
- GUI Framework: wxPython (Native Windows UI)
- Authentication: MSAL (Microsoft Authentication Library)
- API Interaction: Microsoft Graph API via
requests - File Monitoring: Local file lock polling
Getting Started
Prerequisites
Ensure you have Python installed. You will also need to install the following dependencies:
pip install wxPython msal requests
Running the Application
Execute the main script:
python sharepoint_browser.py
Configuration
The application is pre-configured with a CLIENT_ID and TENANT_ID for Microsoft authentication. These are located at the top of sharepoint_browser.py:
CLIENT_ID = '281c91fc-4572-4614-b4d2-e3795d4b502d'
TENANT_ID = 'cce9d2ae-239b-4a22-86bb-fb904c85be79'
TEMP_DIR = "C:\\Temp_SP"
Architecture & Conventions
- Main Entry Point:
sharepoint_browser.pycontains both the GUI logic and the Graph API integration. - Threading: File operations (download, wait, upload) are executed in background threads (
threading.Thread) to keep the GUI responsive. - File Detection: Uses a polling mechanism with
os.rename(local_path, local_path)to detect when the external editor (e.g., Word, Excel) has released the file lock. - Path Handling: Generates unique local filenames using MD5 hashes of the SharePoint item IDs to ensure they remain short and avoid collisions.
Key Files
sharepoint_browser.py: The complete application logic.project_description.md: Original project requirements and context (in Danish).GEMINI.md: This instructional context file.