-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(drive): add +download helper for downloading Drive files #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
nuthalapativarun
wants to merge
9
commits into
googleworkspace:main
from
nuthalapativarun:feat/drive-download
Closed
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
11824ce
feat(drive): add +download helper for downloading Drive files
nuthalapativarun 6b7b809
fixup: sanitize API errors, add --dry-run, stream response to file
nuthalapativarun 6a09110
fixup: address review feedback on +download helper
nuthalapativarun c246259
fixup: address review feedback on +download - backslash, early valida…
nuthalapativarun 08f9861
fixup: address review feedback on +download - dry-run, cross-platform…
nuthalapativarun 4f35687
fixup: address review feedback - consistency fixes in api_error_from_…
nuthalapativarun 499e065
fixup: drop remove_file before rename - tokio::fs::rename overwrites …
nuthalapativarun fa1e32f
fix(drive,executor): sanitize API error fields and randomize tmp file…
nuthalapativarun 06f53d3
fix(drive,executor): use Discovery doc for URLs/scopes and add auth h…
nuthalapativarun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| "@googleworkspace/cli": minor | ||
| --- | ||
|
|
||
| Add `drive +download` helper for downloading Drive files to a local path | ||
|
|
||
| The new `+download` command is a multi-step helper that: | ||
| 1. Fetches file metadata (name, MIME type) to determine how to download | ||
| 2. For Google Workspace native files (Docs, Sheets, Slides) uses `files.export` | ||
| with the caller-supplied `--mime-type` (e.g. `application/pdf`, `text/csv`) | ||
| 3. For all other files uses `files.get?alt=media` | ||
| 4. Writes the response bytes to a local path validated against path traversal | ||
|
|
||
| This complements the existing `+upload` helper and follows all helper | ||
| guidelines: it performs multi-step orchestration that the raw Discovery | ||
| API cannot express as a single call. | ||
|
|
||
| ``` | ||
| gws drive +download --file FILE_ID | ||
| gws drive +download --file FILE_ID --output report.pdf | ||
| gws drive +download --file FILE_ID --mime-type application/pdf | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.