Skip to content

Documents cannot be downloaded #172

@bardo

Description

@bardo

Which version of integration_google are you using?

2.2.0

Which version of Nextcloud are you using?

29.0.1.1

Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.

N/A

Describe the Bug

Certain files cause the following to be logged:

{                                                                                                                                                                                                                    
  "reqId": "$REQUEST",
  "level": 2,
  "time": "2024-05-27T09:13:46+00:00",
  "remoteAddr": "",
  "user": "$USER",
  "app": "integration_google",
  "method": "",
  "url": "--",
  "message": "Google API error : Client error: `GET https://www.googleapis.com/drive/v3/files/$FILE?alt=media` resulted in a `403 Forbidden` response:\n{\n  \"error\": {\n    \"code\": 403,\n    \"message\": \"Only files with binary content can be downloaded. Use Export with Docs E (truncated...)\n",
  "userAgent": "--",
  "version": "29.0.1.1",
  "data": {
    "app": "integration_google"
  }
}

I am unsure which files are causing this because no filename is logged.

Expected Behavior

Files are transferred without errors.

To Reproduce

I'm unsure about the repro because I have no sample to share, however I suspect these files are documents. Searching for the error in GitHub returns multiple results, and it seems that there are ways to properly get them.

An example (in Python, sorry): https://github.com/dixonl90/tuxdrive/blob/e71ca0da16b6e03a05b21ef6b58109deb7d2b03d/tuxdrive#L311-L315

			if ("Only files with binary content can be downloaded." in str(ee)):
				print("File not in binary content. Trying the export method.")
				request = service.files().export_media(fileId=file_id,mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
				fh = open(output_file,'wb') #io.BytesIO()
				downloader = MediaIoBaseDownload(fh, request)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions