omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Uploading tar files to dropbox

    Pythonista
    4
    9
    4927
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • charmaex
      charmaex last edited by

      I'm trying to upload tar files to the dropbox using this:

      get_client().put_file(path_for_tar_in_db, see_below ,True)
      

      I tried so far:

      see_below = open(path,'r')
      see_below = path
      see_below = tarfile.open(path,'r')
      

      Nothing helped so far.
      First one makes corrupted files.
      Second creates txt files.
      And last one just errors.

      Can somebody please help me? :)

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        try open (path,'rb').

        1 Reply Last reply Reply Quote 0
        • charmaex
          charmaex last edited by

          Sadly it isn't working. Still getting a ReadError :-/

          1 Reply Last reply Reply Quote 0
          • ccc
            ccc last edited by

            You wrote:

            get_client().put_file(path_for_tar_in_db, see_below, True)

            but perhaps it should be:

            get_client().put_file(path_for_tar_in_db, see_below, overwrite=True)


            This self-archiving code works for me: tarball_to_dropbox.py

            Running this puts a copy of the current script at the root of a new local .tar file and then pushes that .tar file up to Dropbox. After I run this I can open a terminal on my Mac and:

            $ tar -tvf ~/Dropbox/my_archive.tar

            -rw-r--r-- 0 501 501 5276 Jun 6 15:09 tarball_to_dropbox.py

            $ tar -xvf ~/Dropbox/my_archive.tar

            x tar_to_dropbox.py

            $ cat tarball_to_dropbox.py

            [ ... ]

            1 Reply Last reply Reply Quote 0
            • omz
              omz last edited by

              Could it be that you didn't close the tar file after writing to it? That might explain the corrupted file.

              1 Reply Last reply Reply Quote 0
              • charmaex
                charmaex last edited by

                Thank you ccc I changed the upload to the way you wrote it and the upload seems to work fine now.

                Still getting ReadError when downloading the files like this:

                download_file(s[0], ziel)
                tarfile.open(ziel, 'r:*').extractall('')

                The file appears within the folder still not able to untar.

                1 Reply Last reply Reply Quote 0
                • ccc
                  ccc last edited by

                  Here is the other half of the puzzle. It does roughly the opposite of the script above. It reads the tar file from Dropbox and writes a local copy. It then does a tar extractall on that local copy to recreate the original script (!! It will overwrite !!)

                  tarball_from_dropbox.py

                  1 Reply Last reply Reply Quote 0
                  • charmaex
                    charmaex last edited by

                    Thank you all!
                    cccs solution works fine :)

                    1 Reply Last reply Reply Quote 0
                    • ccc
                      ccc last edited by

                      @charmaex, if it works for you the star my repo.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Powered by NodeBB Forums | Contributors