1

Here are the docs:

FetchContent(*args, **kwargs)

Download file’s content from download_url.

Raises:

ApiRequestError, FileNotUploadedError, FileNotDownloadableError

I tried supplying GoogleDriveFile.metadata['selfLInk'] and it didn't work.... there also a GoogleDriveFile.get method which has 1 argument (i got from errors) I have no idea what that argument is or what it does.. Also GoogleDriveFile.content is none

Just trying to do this:

data=GoogleDriveFile.getcontent()
z=data.read(1024)
while z:
     newdata=do stuff(z)
     localfile.write(newdata)
     z=data.read(1024)
z.close()
localfile.close()

I think pydrive uses the v2 api, I tried doing something liek this: https://youtu.be/-7YH6rdR-tk?t=573 How do I implement that with pydrive? you can see the data part where he writes data to local file.

drive=login()#

z=drive
an='file.ext' #set permission to anyoen with link cna download
zz = z.ListFile({'q': "'root' in parents and trashed=false"}).GetList()
for f in zz:
    if f['title']==an:
        ww=f.metadata['downloadUrl']
        print ww
        print dir(f.FetchContent(ww))
        break
import sys
sys.exit()

['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
Edo Edo
  • 164
  • 2
  • 9
  • 1
    that's GetContentFile which saves to a local file, doesnt return a file like object, the pure API does have a method for this, I saw it here: https://www.youtube.com/watch?v=-7YH6rdR-tk Trying to figure hwo to call it from pydrive – Edo Edo Jul 31 '19 at 05:18
  • GetContent also returns NONE. i'm wondering if i have to set permissions to be able to get that content... – Edo Edo Jul 31 '19 at 05:20
  • Permission set to anyone can download that has link, passed downloadLink to f.FetchContent(arg) still showsup as None – Edo Edo Jul 31 '19 at 05:47

1 Answers1

2

You call FetchContent() then the bytesIO object is .content

Edo Edo
  • 164
  • 2
  • 9