0
I’m trying to upload files from 1-4gb to the google drive(v3) , using phyton3.8, but when I always have errors in the execution: Typeerror: 'Preparedrequest' Object is not callable
def uploaddearquivo(nome:str, caminho:str):
size = os.path.getsize(caminho)
access_token = "###"
headers = {"Authorization": "Bearer " + access_token, "Content-Type": "application/json; charset:UTF-8","X-Upload-Content-Type":'application/octet-stream','X-Upload-Content-Length':str(size)}
params = {
"name": nome,
"mimeType": "application/octet-stream"
}
http = requests.post(
"https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable",
headers=headers,
data=json.dumps(params)
)
file_metadata = {'name':nome}
chunk = 10*(1024*256)
fh = open(caminho,'rb',buffering=chunk)
media = MediaIoBaseUpload(fh,chunksize=chunk,resumable=True,mimetype=FILESTYPE['default'])
# media = MediaFileUpload(caminho,chunksize=chunk,resumable=True)
file = DRIVECONTROLER.files().create(
body=file_metadata,
media_body=media
).execute(http=http,num_retries=3)
media.stream()
response = None
while response is None:
status, response = file.next_chunk()
if status:
print ("Uploaded {}%".format(int(status.progress() * 100)))
print("File ID: {}".format(file.get('id')))
what I’m missing?
In minor uploads I have no problem using only the Mediafileupload