We then make it executable chmod a+x curlgoogle allowing us to use it in an executable manner. Dan Ellis 2020 ''' import os,sys,json if sys.version='3': raw_input = lambda(x): input(x) #Owner information goes here!# name = 'curldata' client_id= ' ' client_secret=' ' # cmd1 = json.loads(os.popen('curl -d "client_id=%s&scope= " '%client_id).read()) str(raw_input('\n Enter %(user_code)s\n\n at %(verification_url)s \n\n Then hit Enter to continue.'%cmd1)) str(raw_input('(twice)')) cmd2 = json.loads(os.popen(('curl -d client_id=%s -d client_secret=%s -d device_code=%s -d grant_type=urn~~3Aietf~~3Aparams~~3Aoauth~~3Agrant-type~~3Adevice_code '%(client_id,client_secret,cmd1)).replace('~~','%')).read()) print(cmd2) # zip files cmd3 = os.popen('zip -r %s.zip %s'%(name,' '.join(sys.argv))).read print(cmd3) cmd4 = os.popen(''' curl -X POST -L \ -H "Authorization: Bearer %s" \ -F "metadata= type=application/json charset=UTF-8" \ -F \ " " '''%(cmd2,name,name)).read() print(cmd4) print('end')
#!/usr/bin/python ''' A quick python script to automate curl->googledrive interfacing This should require nothing more than the system python version and curl. It should require no new dependencies provided curl already exists on the system.
#Go ftp to my google drive code#
We start by creating a new file with nano curlgoogle and enter the following code - remember to add your own personal auth token! Python 2.7 has been chosen as this is still the default python version on older systems, however the script below should also run for python 3. Here we can provide a group of files, it zips them up and then sends them to google drive. Within Apply to each, add Get file content action, File set to Id content. Now we know our commands work we can create an executable script to do all the work for us. Add Apply to each, Input parameter set to output of List files in folder action.