66 lines
2.7 KiB
Markdown
66 lines
2.7 KiB
Markdown
# 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:**
|
|
1. Authenticate via MSAL.
|
|
2. Browse SharePoint sites/folders dynamically.
|
|
3. **Checkout** a file on SharePoint.
|
|
4. **Download** to a short local path (e.g., `C:\Temp_SP\[ShortHash].[ext]`).
|
|
5. **Monitor** local file usage; detect when the editing application is closed.
|
|
6. **Upload** the modified file back to SharePoint.
|
|
7. **Checkin** and clean up local temporary files.
|
|
|
|
## Tech Stack
|
|
|
|
- **Language:** Python 3.x
|
|
- **GUI Framework:** [wxPython](https://www.wxpython.org/) (Native Windows UI)
|
|
- **Authentication:** [MSAL (Microsoft Authentication Library)](https://github.com/AzureAD/microsoft-authentication-library-for-python)
|
|
- **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:
|
|
|
|
```bash
|
|
pip install wxPython msal requests
|
|
```
|
|
|
|
### Running the Application
|
|
|
|
Execute the main script:
|
|
|
|
```bash
|
|
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`:
|
|
|
|
```python
|
|
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.py` contains 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.
|