Spaces:
Sleeping
Sleeping
|
Download docs/FILE_UPLOAD_IMPLEMENTATION.md from marqueeH/notebooklm-mcp-cli: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/spaces/marqueeH/notebooklm-mcp-cli/resolve/main/docs/FILE_UPLOAD_IMPLEMENTATION.md
- Command line
-
hf download hf://spaces/marqueeH/notebooklm-mcp-cli/docs/FILE_UPLOAD_IMPLEMENTATION.md
-
curl -L -o FILE_UPLOAD_IMPLEMENTATION.md https://huggingface.co/spaces/marqueeH/notebooklm-mcp-cli/resolve/main/docs/FILE_UPLOAD_IMPLEMENTATION.md
2.46 kB
| # File Upload Implementation | |
| ## Overview | |
| File upload uses **HTTP Resumable Upload** β the reliable, headless method. | |
| ## HTTP Resumable Upload | |
| ### Implementation | |
| Uses Google's 3-step resumable upload protocol: | |
| 1. **Register source intent** (RPC: `o4cbdc`) β get SOURCE_ID | |
| 2. **Start upload session** (POST to `/upload/_/`) β get upload URL | |
| 3. **Stream file content** β upload URL (memory-efficient streaming) | |
| ### Code Structure | |
| - `SourceMixin._register_file_source()` - Step 1: Register and get SOURCE_ID | |
| - `SourceMixin._start_resumable_upload()` - Step 2: Get upload URL | |
| - `SourceMixin._upload_file_streaming()` - Step 3: Stream file content | |
| - `SourceMixin.add_file()` - Public API that orchestrates all 3 steps | |
| ### Usage | |
| **Python:** | |
| ```python | |
| from notebooklm_tools.core.client import NotebookLMClient | |
| with NotebookLMClient() as client: | |
| result = client.add_file(notebook_id="...", file_path="document.pdf") | |
| # Returns: {"id": "source-id", "title": "document.pdf"} | |
| ``` | |
| **CLI:** | |
| ```bash | |
| nlm source add <notebook-id> --file document.pdf | |
| ``` | |
| **MCP:** | |
| ```python | |
| source_add(notebook_id="...", source_type="file", file_path="/path/to/file.pdf") | |
| ``` | |
| ### Supported File Types | |
| - PDF (`.pdf`) | |
| - Text (`.txt`, `.md`) | |
| - Documents (`.docx`, `.csv`) | |
| - Audio (`.mp3`) | |
| - Video (`.mp4`) | |
| - Images (`.jpg`, `.jpeg`, `.png`) | |
| ### Advantages | |
| - β No Chrome dependency | |
| - β Works in headless/server environments | |
| - β Memory-efficient streaming for large files | |
| - β Faster and more reliable | |
| - β No browser fingerprinting issues | |
| ## Testing | |
| ```bash | |
| # Create a test file | |
| echo "Test content" > test.txt | |
| # Upload the file | |
| nlm source add <notebook-id> --file test.txt | |
| # Verify it was added | |
| nlm source list <notebook-id> | |
| ``` | |
| ## Troubleshooting | |
| ### "File not found" | |
| - **Cause**: The file path doesn't exist or is inaccessible | |
| - **Fix**: Check the file path spelling and permissions | |
| ### "Unsupported file type" | |
| - **Cause**: File extension is not in the supported list | |
| - **Fix**: Convert the file to a supported format | |
| ### Upload times out | |
| - **Cause**: Large file or slow connection | |
| - **Fix**: The upload may still complete on the backend; check notebook sources before retrying | |
| --- | |
| ## Historical Note | |
| A browser-based upload fallback using Chrome automation was previously available (`--browser` flag) but has been removed. NotebookLM's UI now uses the File System Access API which cannot be automated via CDP. The HTTP method is more reliable anyway. | |