Python3:How to keep-alive dropbox.files_upload() . So to download and upload at the same time?

Yashik

I want to download a file from the internet and upload it to dropbox at the same time . I am downloading file as chunks and after every completed chunk I want it to 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.write('')
                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)

But the uploaded file is having a size 0byte

EDIT

I am using f.write('') to save space on the server as i am only getting 512mb as storage

John Zwinck

You should not use multiprocessing for this. Instead, simply download the chunks as you are already doing, and immediately call upload_chunk(a, len(a), offset, upload_id). You do not need the temporary file on disk.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to upload multiple files at the same time using the dropbox java api

From Dev

How to keep a HttpServletRequest alive for an Excel Download

From Dev

Dropbox API HTTP Unity3d upload download

From Dev

python keep-alive connection and download image

From Dev

How to upload complete folder to Dropbox using python

From Dev

Upload/download a whole folder with dropbox api core

From Dev

How to upload attachment at the same time as the document itself

From Dev

How to implement multiple file upload and how to download the files with same id as a zip using carrierwave rails?

From Dev

How to reopen a very same activity / how to keep an activity alive?

From Dev

How do I start a Thread but keep it alive for a certain time?

From Dev

How do I start a Thread but keep it alive for a certain time?

From Dev

How to keep the controller alive

From Dev

How to keep the controller alive

From Dev

Python Webhook to download and upload files with different extensions

From Dev

dropbox API v2 upload large files using python

From Dev

How to keep my Dropbox Files once deleted from Dropbox folder?

From Dev

Is it possible to stream data(Upload) to store on bucket of Google cloud storage and allow to download at the same time?

From Dev

How to upload a file and insert a statement into the database at the same time

From Dev

how to download dropbox files using wget command?

From Dev

upload file to my dropbox from python script

From Dev

How to sort files based on the last upload time?

From Dev

Dropbox partial upload

From Dev

Upload a file into dropbox folder

From Dev

How to upload files in Symfony 3

From Dev

How to pop up an alert in Python and at the same time keep the process running?

From Dev

How to keep alive my BroadcastReceiver

From Dev

How to keep connection alive in pgAdmin

From Dev

How to keep an RDP session alive?

From Dev

How to keep SSH connection alive?

Related Related

  1. 1

    How to upload multiple files at the same time using the dropbox java api

  2. 2

    How to keep a HttpServletRequest alive for an Excel Download

  3. 3

    Dropbox API HTTP Unity3d upload download

  4. 4

    python keep-alive connection and download image

  5. 5

    How to upload complete folder to Dropbox using python

  6. 6

    Upload/download a whole folder with dropbox api core

  7. 7

    How to upload attachment at the same time as the document itself

  8. 8

    How to implement multiple file upload and how to download the files with same id as a zip using carrierwave rails?

  9. 9

    How to reopen a very same activity / how to keep an activity alive?

  10. 10

    How do I start a Thread but keep it alive for a certain time?

  11. 11

    How do I start a Thread but keep it alive for a certain time?

  12. 12

    How to keep the controller alive

  13. 13

    How to keep the controller alive

  14. 14

    Python Webhook to download and upload files with different extensions

  15. 15

    dropbox API v2 upload large files using python

  16. 16

    How to keep my Dropbox Files once deleted from Dropbox folder?

  17. 17

    Is it possible to stream data(Upload) to store on bucket of Google cloud storage and allow to download at the same time?

  18. 18

    How to upload a file and insert a statement into the database at the same time

  19. 19

    how to download dropbox files using wget command?

  20. 20

    upload file to my dropbox from python script

  21. 21

    How to sort files based on the last upload time?

  22. 22

    Dropbox partial upload

  23. 23

    Upload a file into dropbox folder

  24. 24

    How to upload files in Symfony 3

  25. 25

    How to pop up an alert in Python and at the same time keep the process running?

  26. 26

    How to keep alive my BroadcastReceiver

  27. 27

    How to keep connection alive in pgAdmin

  28. 28

    How to keep an RDP session alive?

  29. 29

    How to keep SSH connection alive?

HotTag

Archive