Files
Claude eeab6748ae Fix node failing to load, read client ID from config, harden uploads
- CLIENT_ID = YOUR_CLIENt_ID was not a string, so importing the node raised
  NameError and it never appeared in ComfyUI until the source was edited.
  The client ID is now read from onedrive_config.json next to the node or
  the ONEDRIVE_CLIENT_ID environment variable, and the MSAL app is created
  on first use, so a missing ID shows a clear message instead of a crash.
- Folder/file paths are URL-encoded; folder names containing '#', '%' or '?'
  previously uploaded to the wrong place or failed.
- Uploads have a timeout (they could hang the queue forever) and reuse one
  HTTP connection per batch.
- Token cache is loaded once instead of from disk on every run.
- File numbering uses an in-memory counter instead of creating an empty
  marker file in the temp folder for every image.
- Added requirements.txt (msal was never declared) and a .gitignore so the
  sign-in token and client ID are never committed.
- README: setup steps for the client ID; corrected the filename description.

Version 1.1.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Lm4YDXhwj49hAA1RKS58Q
2026-10-22 12:00:22 +00:00

35 lines
1.9 KiB
Markdown

# ComfyUI-Save_To_OneDrive
Saves images directly to OneDrive using Microsoft's free API service
## Save Image To OneDrive
<img width="301" height="364" alt="image" src="https://github.com/user-attachments/assets/0cf213dc-510b-44b5-8e0c-3c9209bfddd6" />
___
## IMPORTANT
If you don't know how to get the onedrive_msal_token from Microsoft, I have made a very detailed guide on how. The guide is available on my Patreon: [Save Image To OneDrive - Guide](https://www.patreon.com/posts/comfy-space-129775871?utm_medium=clipboard_copy&utm_source=copyLink&utm_campaign=postshare_creator&utm_content=join_link)
___
### SETUP
Create a file named `onedrive_config.json` in this node's folder (`custom_nodes/ComfyUI-Save_To_OneDrive/`) with your Azure app's client ID:
```json
{"client_id": "your-application-client-id"}
```
Alternatively, set the `ONEDRIVE_CLIENT_ID` environment variable. The first time the node runs, the console shows a link and a code: open the link, enter the code and sign in, and the node continues the upload. After that it stays signed in.
### INSTRUCTIONS
This node and it's code is completely free to use. It should be noted that you will have to get your own **onedrive_msal_token** with Microsoft in order for the node to work preperly. The **onedrive_msal_token** are needed to give the node access to your OneDrive and to create folders as well as save images and videos.
The node will create folders you specify in the node itself if they aren't already created in your OneDrive.
**Folder structure**: Rootfolder/subfolder/subfolder
**Filename prefix**: Images are numbered, so with the prefix "IMG" they are saved as IMG_00001.png, IMG_00002.png and so on (or .jpeg / .webp). If a file with that name already exists in the folder, OneDrive adds a number to the new one instead of overwriting it.
**File Format**: Format available is PNG, JPEG and WEBP