# Photo Upload to Drive — API approach

**Status: UPLOAD WORKS, INLINE EMBED IN DOCS FAILS**

The `embed_photos.py` script at `/root/.hermes/embed_photos.py` uploads photos to Drive and generates public `uc?export=view&id=...` links. This part works.

Inline image embedding into Google Docs via API does NOT work cleanly — the API only supports inserting images via `insertInlineImage` with a `location` and `objectSize`, but the image must already be on the web (not a Drive export URL). Thumbnail links or Drive view URLs render as links, not inline images.

## What works instead

1. Upload photos to Drive manually OR use `embed_photos.py` to upload and get public links
2. In the Google Doc, insert the Drive links as plain text
3. **Better**: Skip the doc entirely for photos. Just:
   - Save photos to `/home/ccuser/opsman-work/daily/`
   - Email the report to admin@lfcs.com.au with a Drive folder link
   - Do photo embedding manually on desktop (2 min, works properly)

## embed_photos.py usage

```bash
python /root/.hermes/embed_photos.py
```

Requires `google_token.json` with `drive.file` + `documents` scopes.

## Key API calls

```python
from googleapiclient.discovery import build
from google.oauth2.credentials import Credentials
from googleapiclient.http import MediaFileUpload

creds = Credentials.from_authorized_user_file('google_token.json', [
    'https://www.googleapis.com/auth/drive.file',
    'https://www.googleapis.com/auth/documents'
])
drive = build('drive', 'v3', credentials=creds)

# Upload
media = MediaFileUpload(photo_path, mimetype='image/jpeg')
uploaded = drive.files().create(
    body={'name': fname, 'mimeType': 'image/jpeg'},
    media_body=media,
    fields='id, webViewLink'
).execute()

# Make public
drive.permissions().create(
    fileId=uploaded['id'],
    body={'type': 'anyone', 'role': 'reader'}
).execute()

# Public image URL
image_url = f"https://drive.google.com/uc?export=view&id={uploaded['id']}"
```