Skip to content
Open
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
18 changes: 16 additions & 2 deletions crates/google-workspace-cli/src/helpers/drive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ EXAMPLES:

TIPS:
MIME type is detected automatically.
Filename is inferred from the local path unless --name is given.",
Filename is inferred from the local path unless --name is given.
Shared Drive parents are supported automatically.",
),
);
cmd
Expand Down Expand Up @@ -94,6 +95,7 @@ TIPS:
let metadata = build_metadata(&filename, parent_id.map(|s| s.as_str()));

let body_str = metadata.to_string();
let params_str = build_upload_params().to_string();

let scopes: Vec<&str> = create_method.scopes.iter().map(|s| s.as_str()).collect();
let (token, auth_method) = match auth::get_token(&scopes).await {
Expand All @@ -105,7 +107,7 @@ TIPS:
executor::execute_method(
doc,
create_method,
None,
Some(&params_str),
Some(&body_str),
token.as_deref(),
auth_method,
Expand Down Expand Up @@ -154,6 +156,12 @@ fn build_metadata(filename: &str, parent_id: Option<&str>) -> Value {
metadata
}

fn build_upload_params() -> Value {
json!({
"supportsAllDrives": true
})
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -193,4 +201,10 @@ mod tests {
assert_eq!(meta["name"], "file.txt");
assert_eq!(meta["parents"][0], "folder123");
}

#[test]
fn test_build_upload_params_supports_shared_drives() {
let params = build_upload_params();
assert_eq!(params["supportsAllDrives"], true);
}
}
1 change: 1 addition & 0 deletions skills/gws-drive-upload/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ gws drive +upload ./data.csv --name 'Sales Data.csv'

- MIME type is detected automatically.
- Filename is inferred from the local path unless --name is given.
- Shared Drive parents are supported automatically.

> [!CAUTION]
> This is a **write** command — confirm with the user before executing.
Expand Down
Loading