I want to download a file from the web and upload it to dropbox.
import multiprocessing as m
import requests as rr
import dropbox
url='
http://www.onirikal.com/videos/mp4/battle_games.mp4'
db=dropbox.Dropbox(Accesstoken)
def d(url):
r=rr.get(url,stream=True)
with open('file.mp4','wb')as f:
for a in r.iter_content(chunk_size=1000000):
if a:
f.truncate(0)
f.write(a)
def u():
try:
with open('file.mp4','rb')as ff:
db.files_upload(ff.read(),'/file.mp4')
except FileNotFoundError:
pass
if __name__=='__main__':
p=m.Pool()
re= p.apply_async(d,[url])
ree=p.apply_async(u)
re.get(timeout=10)
ree.get(timeout=10)
The file uploaded is 0bytes