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
-
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? :)
-
try
open (path,'rb')
. -
Sadly it isn't working. Still getting a ReadError :-/
-
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
[ ... ]
-
Could it be that you didn't close the tar file after writing to it? That might explain the corrupted file.
-
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.
-
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 !!)
-
Thank you all!
cccs solution works fine :) -