Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/google-workspace-cli/registry/recipes.toml
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ services = [ "gmail", "drive" ]
steps = [
"Search for emails with attachments: `gws gmail users messages list --params '{\"userId\": \"me\", \"q\": \"has:attachment from:client@example.com\"}' --format table`",
"Get message details: `gws gmail users messages get --params '{\"userId\": \"me\", \"id\": \"MESSAGE_ID\"}'`",
"Download attachment: `gws gmail users messages attachments get --params '{\"userId\": \"me\", \"messageId\": \"MESSAGE_ID\", \"id\": \"ATTACHMENT_ID\"}'`",
"Upload to Drive folder: `gws drive +upload --file ./attachment.pdf --parent FOLDER_ID`"
"Download and decode attachment bytes: `gws gmail users messages attachments get --params '{\"userId\": \"me\", \"messageId\": \"MESSAGE_ID\", \"id\": \"ATTACHMENT_ID\"}' | jq -r '.data' | python3 -c 'import base64,sys; d=sys.stdin.read().strip(); sys.stdout.buffer.write(base64.urlsafe_b64decode(d + \"=\" * (-len(d) % 4)))' > attachment.pdf`",
"Upload to Drive folder: `gws drive +upload ./attachment.pdf --parent FOLDER_ID`"
]

[[recipes]]
Expand Down
11 changes: 8 additions & 3 deletions skills/recipe-save-email-attachments/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ Find Gmail messages with attachments and save them to a Google Drive folder.

1. Search for emails with attachments: `gws gmail users messages list --params '{"userId": "me", "q": "has:attachment from:client@example.com"}' --format table`
2. Get message details: `gws gmail users messages get --params '{"userId": "me", "id": "MESSAGE_ID"}'`
3. Download attachment: `gws gmail users messages attachments get --params '{"userId": "me", "messageId": "MESSAGE_ID", "id": "ATTACHMENT_ID"}'`
4. Upload to Drive folder: `gws drive +upload --file ./attachment.pdf --parent FOLDER_ID`

3. Download and decode attachment bytes:
```bash
gws gmail users messages attachments get --params '{"userId": "me", "messageId": "MESSAGE_ID", "id": "ATTACHMENT_ID"}' \
| jq -r '.data' \
| python3 -c 'import base64,sys; d=sys.stdin.read().strip(); sys.stdout.buffer.write(base64.urlsafe_b64decode(d + "=" * (-len(d) % 4)))' \
> attachment.pdf
```
4. Upload to Drive folder: `gws drive +upload ./attachment.pdf --parent FOLDER_ID`
Loading