pythondash / envios.py
InstitutoMIX's picture
Upload 10 files
e87112e
import json
import requests
import tempfile
def convertion(arquivo,nome,codeLocal):
#st.text(arquivo)
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
temp_file.write(arquivo.read())
temp_file.seek(0)
temp_file_path = temp_file.name
#st.text(temp_file_path)
EnvioDrive(temp_file_path,nome,codeLocal)
def EnvioDrive(arquivo,nome,codeLocal):
headers = {"Authorization": "Bearer ya29.a0AfB_byCCV4qg-2G_UC-YLKIf1hAHYC1bvGnfWyoC0-rgeu0oIcr4sqWP55yQCum8F57QMydDMIOlsGo9hyPpeUhxJ3FfXj5epin5Urfx8yAVVIgBoGFXRUTbJvU6Gvsu7P_B8o7n0K9f99WuJWkLDQTtB1oEaCgYKAQMSARESFQHsvYls4ErYFpVlO_aOj0tzgW7pMA0163"}
para = {
"name": nome,
"parents":[codeLocal]
#["167kh3HWDdZ1nXSrjp0q2xLOv4kn55miodb02lQTGwSq2csCjE_XlTPIOmS6tSsFmxdMMv-oh"]
}
files = {
'data': ('metadata', json.dumps(para), 'application/json; charset=UTF-8'),
'file': open(arquivo, "rb")
}
r = requests.post(
"https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart",
headers=headers,
files=files
)
print(r.text)
''' if __name__ == '__main__':
print('oi guilherme')
EnvioDrive('./style.css','meuEstiloCSS','1NaucQ1-vhkQKOY993Su8EN7ooguPpoFQIkaRxDeu772n5APURpXD1Ni2tFBTP4clixSme9DT')
'''