Commit ad6e8cde authored by Marcel Rieger's avatar Marcel Rieger
Browse files

File: Update upload, binary check needed.

parent 4800be0f
......@@ -151,14 +151,11 @@ class FSAjaxController(AbstractController):
def handleUpload(self, path, parts):
fs = self.get('fs')
print"################################################"
print path
print fs
print"################################################"
path = fs.expand(path)
for part in parts:
f = part.file
name = str(part.filename)
print "upload file name:", name
# check mime type, i.e. get the content type depending on the file
# extension
......@@ -169,7 +166,10 @@ class FSAjaxController(AbstractController):
'The file extension \'%s\' is not supported by this server' % ext)
# save the content using the fs
fs.save_file(os.path.join(path, name), base64.b64encode(f.read()), binary=True, force=True)
print "here"
# content = base64.b64encode(c)
fs.save_file(os.path.join(path, name), f.read(), binary=True, force=True)
print "here too"
@cherrypy.expose
@cherrypy.tools.ajax()
......
......@@ -448,17 +448,10 @@ var FileBaseActions = Class.extend({
self.FileBase.updateView();
console.log(e);
console.log(data);
vispa.messenger._pushMessage({
// $.Helpers.bytesToString(data.loaded),
text: 'Uploaded ' + data,
icon: 'glyphicon glyphicon-ok-sign'
});
vispa.messenger.info('Upload succeeded', 'glyphicon glyphicon-ok-sign');
},
fail: function() {
vispa.messenger._pushMessage({
text: 'Upload failed!',
icon: 'ui-icon-alert'
});
vispa.messenger.info('Upload failed', 'glyphicon glyphicon-warning-sign');
}
}).trigger('click');
return this;
......
......@@ -224,11 +224,6 @@ class FileSystem(object):
fullpath = os.path.join(path, name)
logger.debug("\n\n")
logger.debug(path)
logger.debug(paths)
logger.debug("\n\n")
with ZipFile(fullpath, "w") as archive:
# archive = ZipFile(fullpath, "w")
path = path if path.startswith(os.sep) else path
......@@ -277,13 +272,20 @@ class FileSystem(object):
os.remove(fullsrc)
def save_file(self, path, content, binary=False, force=True):
logger.info(path)
logger.info("\n\n")
return
path = self.expand(path)
# check if file already exists
if os.path.exists(path) and not force:
return False
out = open(path, "wb")
if binary:
out = file(path, "wb")
content = base64.b64decode(content)
else:
out = file(path, "w")
logger.info("saved")
logger.info("\n\n")
out.write(content)
out.close()
return True
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment