def files_message_lib(self, uuid): """04返回文件""" files = Files.by_uuid(uuid) try: username = files.users[0].username except IndexError: username = files.files_users_del[0].username return files, username
def download_files_qiniu_lib(self, uuid): """12 从下载文件""" if uuid == '': return {'status': False, 'msg': '没有文件ID'} old_file = Files.by_uuid(uuid) if old_file is None: return {'status': False, 'msg': '文件不存在'} qiniu_url = 'http://p7bj6aatj.bkt.clouddn.com/{}'.format(uuid) url = down_qiniu_file(qiniu_url) print(url) return {'status': True, 'data': url}
def file_finaly_del_libs(self, uuid): """07彻底删除文件""" file = Files.by_uuid(uuid) if file: try: user = self.current_user except Exception as e: print "nonexitence current_user" # 从回收站列表删除 user.users_files_del.remove(file) self.db.add(user) self.db.commit() return {'status': True, 'msg': '彻底删除成功'}
def file_rev_libs(self, uuid): """08恢复文件""" file = Files.by_uuid(uuid) if file: try: user = self.current_user except Exception as e: print "nonexitence current_user" # 添加到文件列表添加 user.files.append(file) # 回收站列表中移除 user.users_files_del.remove(file) self.db.add(user) self.db.commit() return {'status': True, 'msg': '恢复成功'}
def file_del_libs(self, uuid): """06删除文件""" file = Files.by_uuid(uuid) if file: try: user = self.current_user except Exception: print "nonexitence current_user" user.files.remove(file) # 从文件列表删除 user.users_files_del.append(file) # 添加到回收站列表 self.db.add(user) self.db.commit() # print "files_del type is :%s"% type(user.users_files_del) # print "files_del is :%s"% user.users_files_del return {'status': True, 'msg': '删除到回收站成功'}