Skip to content

Commit

Permalink
GoogleDrive: fix error in file-upload command (demisto#33290)
Browse files Browse the repository at this point in the history
* fix the error

* fix validation

* CR change
  • Loading branch information
ilappe authored Mar 11, 2024
1 parent 490f382 commit ae6756c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,8 @@ def file_upload_command(client: 'GSuiteClient', args: dict[str, str]) -> Command
file_path = demisto.getFilePath(file_entry_id)

user_id = args.get('user_id') or client.user_id
supports_all_drives = argToBoolean(args.get('supports_all_drives', False))

client.set_authorized_http(scopes=COMMAND_SCOPES['FILES'], subject=user_id)
drive_service = discovery.build(serviceName=SERVICE_NAME, version=API_VERSION, http=client.authorized_http)
body: dict[str, str] = assign_params(
Expand All @@ -1242,6 +1244,7 @@ def file_upload_command(client: 'GSuiteClient', args: dict[str, str]) -> Command
media = MediaFileUpload(file_path['path'])
file = drive_service.files().create(body=body,
media_body=media,
supportsAllDrives=supports_all_drives,
fields='*'
).execute()
return handle_response_file_single(file, args)
Expand Down
9 changes: 8 additions & 1 deletion Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2115,6 +2115,13 @@ script:
description: The file's Entry ID.
- name: parent
description: The ID of the parent folder which contains the file. If not specified as part of a create request, the file will be placed directly in the user's My Drive folder.
- auto: PREDEFINED
defaultValue: "false"
description: 'Whether the requesting application supports both My Drives and shared drives.'
name: supports_all_drives
predefined:
- "true"
- "false"
outputs:
- contextPath: GoogleDrive.File.File.id
description: The ID of the file.
Expand Down Expand Up @@ -3103,7 +3110,7 @@ script:
- contextPath: GoogleDrive.File.Parents
description: The IDs of the parent folders which contain the file.
type: String
dockerimage: demisto/googleapi-python3:1.0.0.89217
dockerimage: demisto/googleapi-python3:1.0.0.89487
isfetch: true
runonce: false
script: "-"
Expand Down
1 change: 1 addition & 0 deletions Packs/GoogleDrive/Integrations/GoogleDrive/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ Creates a new file.
| file_name | The name of the file to upload. | Optional |
| entry_id | The file's Entry ID. | Optional |
| parent | The ID of the parent folder which contains the file. If not specified as part of a create request, the file will be placed directly in the user's My Drive folder. | Optional |
| supports_all_drives | Whether the requesting application supports both My Drives and shared drives. Possible values: "true" and "false". Default is "false". | Optional |

#### Context Output

Expand Down
7 changes: 7 additions & 0 deletions Packs/GoogleDrive/ReleaseNotes/1_3_5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

#### Integrations

##### Google Drive

- Fixed an issue where **google-drive-file-upload** command failed to upload file to a shared drive.
- Updated the Docker image to: *demisto/googleapi-python3:1.0.0.89487*.
2 changes: 1 addition & 1 deletion Packs/GoogleDrive/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Google Drive",
"description": "Google Drive allows users to store files on their servers, synchronize files across devices, and share files. This integration helps you to create a new drive, query past activity and view change logs performed by the users, as well as list drives and files, and manage their permissions.",
"support": "xsoar",
"currentVersion": "1.3.4",
"currentVersion": "1.3.5",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit ae6756c

Please sign in to comment.