integration_google icon indicating copy to clipboard operation
integration_google copied to clipboard

Documents cannot be downloaded

Open bardo opened this issue 1 year ago • 9 comments

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)

bardo avatar May 27 '24 09:05 bardo

Hello :wave:

Thank you for taking the time to open this issue with integration_google. I know it's frustrating when software causes problems. You have made the right choice to come here and open an issue to make sure your problem gets looked at and if possible solved. We try to answer all issues and if possible fix all bugs here, but it sometimes takes a while until we get to it. Until then, please be patient. If you are strugging to set up the app, have a look at this video: https://www.youtube.com/watch?v=h_teJPg2wEk Note also that GitHub is a place where people meet to make software better together. Nobody here is under any obligation to help you, solve your problems or deliver on any expectations or demands you may have, but if enough people come together we can collaborate to make this software better. For everyone. Thus, if you can, you could also look at other issues to see whether you can help other people with your knowledge and experience. If you have coding experience it would also be awesome if you could step up to dive into the code and try to fix the odd bug yourself. Everyone will be thankful for extra helping hands! One last word: If you feel, at any point, like you need to vent, this is not the place for it; you can go to the forum, to twitter or somewhere else. But this is a technical issue tracker, so please make sure to focus on the tech and keep your opinions to yourself. (Also see our Code of Conduct. Really.)

I look forward to working with you on this issue Cheers :blue_heart:

github-actions[bot] avatar May 27 '24 09:05 github-actions[bot]

You might be able to find out which file it is by accessing a file in your drive via the web UI and then replacing the id in the URL with the id in the Error URL. That might open the file in your browser.

marcelklehr avatar Jun 04 '24 09:06 marcelklehr

We do try to infer from the mime type which files are documents and automatically use the export method.

marcelklehr avatar Jun 04 '24 09:06 marcelklehr

Unfortunately I cannot access the file on Drive because it's from one of my users. I'll try to repro on my account though.

What I could see is that the Activity log shows the creation and subsequent deletion of docx/pptx files, so I assume that those are the problematic ones. Would there be any difference if ODF formats were selected in the settings?

Can you also point me to the logic that processes these files? I am not a PHP expert, but I can try to have a look.

bardo avatar Jul 04 '24 09:07 bardo

Hello :wave: This issue appears to have had no activity for 3 months. We cannot keep track of whether individual issues have resolved themselves or still require attention without user interaction. We're thus adding the stale label to this issue to schedule it for getting closed in 5 days time. If you believe this issue is still valid and should be fixed, you can add a comment or remove the label to avoid it getting closed.

Cheers :blue_heart:

github-actions[bot] avatar Oct 03 '24 02:10 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Oct 08 '24 02:10 github-actions[bot]

Sorry for the delay! This is the code that downloads the files: https://github.com/nextcloud/integration_google/blob/main/lib/Service/GoogleDriveAPIService.php#L704-L717

And this is the import routine: https://github.com/nextcloud/integration_google/blob/main/lib/Service/GoogleDriveAPIService.php#L244-L398

marcelklehr avatar Oct 08 '24 06:10 marcelklehr

Hello :wave: This issue appears to have had no activity for 3 months. We cannot keep track of whether individual issues have resolved themselves or still require attention without user interaction. We're thus adding the stale label to this issue to schedule it for getting closed in 5 days time. If you believe this issue is still valid and should be fixed, you can add a comment or remove the label to avoid it getting closed.

Cheers :blue_heart:

github-actions[bot] avatar Jan 07 '25 02:01 github-actions[bot]

@bardo Any news on this?

marcelklehr avatar Mar 04 '25 14:03 marcelklehr