Nov-05-2018, 08:33 AM
i solved the multi files issue by adding (i)
import json import requests import glob def upload_1(): headers = {"Authorization": "Bearer access token"} #put ur access token after the word 'Bearer ' qassam = glob.glob("/root/Downloads/*.pdf") for i in qassam: qassam = "\n".join(qassam) print i para = { "name": (i), #file name to be uploaded "parents": ["1bEBQugJ4GVnEECElKztEgq9tHbFdYetu"] # make a folder on drive in which you want to upload files; then open that folder; the last thing in present url will be folder id } files = { 'data': ('metadata', json.dumps(para), 'application/json; charset=UTF-8'), 'file': ('application/zip',open(i, "rb")) # replace 'application/zip' by 'image/png' for png images; similarly 'image/jpeg' (also replace your file name) } r = requests.post( "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", headers=headers, files=files ) print(r.text) upload_1()but i have a new issue !! the access token is expired every 1 hour !! so i must go the : https://developers.google.com/oauthplayground/ and get the new one and replace it manually !! i dont need that i need to do this auto !! is there anyway to get a new token by python !!