google-api-python-client icon indicating copy to clipboard operation
google-api-python-client copied to clipboard

export_media() exported content is limited to 10MB

Open serhiorazin opened this issue 3 years ago • 2 comments

Builtin method has a limit of 10Mb: https://googleapis.github.io/google-api-python-client/docs/dyn/drive_v3.files.html#export_media

You can request exportLinks field in the Files: list:

curl \
  'https://www.googleapis.com/drive/v3/files/[FILE_ID]?fields=exportLinks' \
  --header 'Authorization: Bearer [ACCESS_TOKEN]' \
  --header 'Accept: application/json'

That will return something like this (these are links I got for a Google Slides presentation):

{
 "exportLinks": {
  "application/vnd.oasis.opendocument.presentation": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=odp",
  "application/pdf": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=pdf",
  "application/vnd.openxmlformats-officedocument.presentationml.presentation": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=pptx",
  "text/plain": "https://docs.google.com/feeds/download/presentations/Export?id=[FILE_ID]&exportFormat=txt"
 }
}

And those urls don't have such a hard size limit.

It'll be more convenient to use export_media method without this limit.

serhiorazin avatar Jun 29 '22 12:06 serhiorazin

Maybe it is not an issue, but future request. Maybe there is a way to get the content from the exportLink api using the library instead of using export_media method?

serhiorazin avatar Jun 30 '22 14:06 serhiorazin

Can I work on this?

My mission plan ... should you choose to accept ... could involve:

  1. Add a boolean flag/parameter to the export and export_media function that enables the use of exportLink attribute of files to download the required docs, which of course bypasses the whole 10 Mb limit eish.
  2. A new separate function, could be called anything, eg. media_download, that does the same as 1 above, except this time, we don't corrupt export or export_media that directly mirrors google's API, keeping things clean.

Or does this project have a thing against adding functions that are not officially supported??

TEMHITHORPHE avatar Jan 02 '23 07:01 TEMHITHORPHE