def create_file(self, filename, user=None): file = File() if user is None: user = self.get_current_user() file.author = user file.name = filename key = file.put() self.create_permission(file, file.author, ACCESS_WRITE) #self.redirect('/file?' + urllib.urlencode({'id': key})) return key
def uploads(): if request.method == 'GET': return render_template('uploads.html') else: f = request.files['file'] f.save( os.path.join(os.path.dirname('uploads'), secure_filename(f.filename))) file = File(file_name=str(secure_filename(f.filename))) user_id = session.get('user_id') user = User.query.filter(User.id == user_id).first() file.author = user db.session.add(file) db.session.commit() return redirect(url_for('downloads'))