Finish Directory.upload() function

master
Sven Slootweg 12 years ago
parent ba25546a6c
commit adf3e9bb4a

1
.gitignore vendored

@ -1 +1,2 @@
*.pyc
test

@ -290,16 +290,21 @@ class Directory:
if filename is None:
if type(filedata) is str:
filename = self._sanitize_filename(os.path.basename(filedata))
filename = self.filesystem._sanitize_filename(os.path.basename(filedata))
elif type(filedata) is file:
if type(filedata.name) is str:
filename = self._sanitize_filename(filedata.name)
filename = self.filesystem._sanitize_filename(filedata.name)
else:
# We could not determine the filename for the input... let's generate something.
filename = ''.join(random.choice(string.ascii_lowercase + string.digits) for x in range(15))
else:
raise UploadException("The given file is not a valid string or file object.")
new_file = self.filesystem.upload(filedata)
new_file.attach(self, filename)
return new_file
def attach(self, directory, filename=None, **kwargs):
"""Attach this Directory to a Directory in the filesystem.

@ -18,15 +18,18 @@ import pytahoe
fs = pytahoe.Filesystem("http://tahoe.ccnmtl.columbia.edu/")
tfile = fs.File("URI:CHK:iyq5houj2fqavmnqccqezcssle:5px5tdctmmvci4al2r3vskpblhrepuugfe6ghiuutpe6cllvo36a:3:10:997")
print tfile.read(65)
#tfile = fs.File("URI:CHK:iyq5houj2fqavmnqccqezcssle:5px5tdctmmvci4al2r3vskpblhrepuugfe6ghiuutpe6cllvo36a:3:10:997")
#print tfile.read(65)
#print fs
#
#tfile = fs.upload("test.py")
#print tfile
#
#tdir = fs.Directory("URI:DIR2:cbk47f5lybaj5qh6bm6eedezwe:m525plntx47u44xvf44r6rliec3gp6yeyio7olndibtke75zb6fa")
tdir = fs.Directory("URI:DIR2:cbk47f5lybaj5qh6bm6eedezwe:m525plntx47u44xvf44r6rliec3gp6yeyio7olndibtke75zb6fa")
print tdir.upload("test.py")
#print tdir
#
#print tfile.attach(tdir, "sample // file 2.py")

Loading…
Cancel
Save