示例#1
0
文件: views.py 项目: shinkou/pywfman
def fbnewdir(req, path=''):
	"""
	Create new node as folder
	"""
	try:
		fw = FWriter(path)
		fw.newdir()
		c = 200
		s = 'Folder "%s" created successfully.' % path
	except Exception as e:
		c = 500
		s = 'Error creating folder "%s": %s' % (path, e.message)
		logging.exception(s)
	return HttpResponse(s, CONTENT_TEXT, c)
示例#2
0
文件: views.py 项目: shinkou/pywfman
def fbupload(req):
	"""
	Upload file
	"""
	c = 400
	s = 'File upload incomplete.'
	if req.POST and req.FILES:
		try:
			path = req.POST['path']
			fname = req.FILES['file'].name
			fw = FWriter(os.path.join(path, fname))
			fw.newfile(req.FILES['file'])
			c = 200
			s = 'File "%s" uploaded successfully.' % fname
		except Exception as e:
			c = 500
			s = 'Error uploading file "%s": %s' % (fname, e.message)
			logging.exception(s)
	return HttpResponse(s, CONTENT_TEXT, c)