def send(parent_id): parent = File.get(parent_id) root = parent.root_folder_id if parent.mime == 'root': root = parent.id company = utils.db.query_filter(Company, journalist_folder_file_id=root).one() if EmployeeHasRightAtCompany(RIGHT_AT_COMPANY.FILES_UPLOAD).check(company_id=company.id) is not True: return jsonify({'error': True}) data = request.form uploaded_file = request.files['file'] name = File.get_unique_name(urllib.parse.unquote(uploaded_file.filename).replace( '"', '_').replace('*', '_').replace('/', '_').replace('\\', '_'), data.get('ftype'), parent.id) data.get('ftype') if re.match('^video/.*', data.get('ftype')): body = {'title': uploaded_file.filename, 'description': '', 'status': 'public'} youtube = YoutubeApi(body_dict=body, video_file=uploaded_file.stream.read(-1), chunk_info=dict(chunk_size=int(data.get('chunkSize')), chunk_number=int(data.get('chunkNumber')), total_size=int(data.get('totalSize'))), company_id=company.id, root_folder_id=company.journalist_folder_file_id, parent_folder_id=parent_id) file = youtube.upload() else: file = File.upload(name, data, parent.id, root, company, content=uploaded_file.stream.read(-1)) return jsonify({'result': {'size': 0}, 'error': True if file == 'error' else False, 'file_id': file})
def cut(json): file = File.get(json['params']['id']) if not file or not File.if_action_allowed( 'upload', get_company_from_folder(json['params']['id']).id): return False return file.move_to(json['params']['folder_id'])
def send(parent_id): file = request.files['file'] parent = File.get(parent_id) root = parent.root_folder_id if parent.mime == 'root': root = parent.id data = request.form uploaded_file = request.files['file'] name = File.get_unique_name(urllib.parse.unquote(uploaded_file.filename).replace('"','_').replace('*','_').replace('/','_').replace('\\','_'), data.get('ftype'), parent.id) company = db(Company, journalist_folder_file_id=root).one() if re.match('^video/.*', data.get('ftype')): body = {'title': file.filename, 'description': '', 'status': 'public'} youtube = YoutubeApi(body_dict=body, video_file=file.stream.read(-1), chunk_info=dict(chunk_size=int(data.get('chunkSize')), chunk_number=int(data.get('chunkNumber')), total_size=int(data.get('totalSize'))), company_id=company.id, root_folder_id=company.journalist_folder_file_id, parent_folder_id=parent_id) youtube.upload() else: File.upload(name, data, parent.id, root, content=uploaded_file.stream.read(-1)) return jsonify({'result': {'size': 0}})
def remove(json, file_id): file = File.get(file_id) if not file: return False ancestors = File.ancestors(file.parent_id) return file.remove( db(Company, journalist_folder_file_id=ancestors[0]).first().id)
def send(parent_id): file = request.files['file'] parent = File.get(parent_id) root = parent.root_folder_id if parent.mime == 'root': root = parent.id data = request.form uploaded_file = request.files['file'] name = File.get_unique_name( urllib.parse.unquote(uploaded_file.filename).replace('"', '_').replace( '*', '_').replace('/', '_').replace('\\', '_'), data.get('ftype'), parent.id) company = db(Company, journalist_folder_file_id=root).one() if re.match('^video/.*', data.get('ftype')): body = {'title': file.filename, 'description': '', 'status': 'public'} youtube = YoutubeApi(body_dict=body, video_file=file.stream.read(-1), chunk_info=dict( chunk_size=int(data.get('chunkSize')), chunk_number=int(data.get('chunkNumber')), total_size=int(data.get('totalSize'))), company_id=company.id, root_folder_id=company.journalist_folder_file_id, parent_folder_id=parent_id) youtube.upload() else: File.upload(name, data, parent.id, root, content=uploaded_file.stream.read(-1)) return jsonify({'result': {'size': 0}})
def send(parent_id): parent = File.get(parent_id) root = parent.root_folder_id if parent.mime == 'root': root = parent.id company = db(Company, journalist_folder_file_id=root).one() if FilemanagerRights(company=company).action_is_allowed(FilemanagerRights.ACTIONS['UPLOAD']) != True: return jsonify({'error': True}) data = request.form uploaded_file = request.files['file'] name = File.get_unique_name(urllib.parse.unquote(uploaded_file.filename).replace( '"', '_').replace('*', '_').replace('/', '_').replace('\\', '_'), data.get('ftype'), parent.id) data.get('ftype') if re.match('^video/.*', data.get('ftype')): body = {'title': uploaded_file.filename, 'description': '', 'status': 'public'} youtube = YoutubeApi(body_dict=body, video_file=uploaded_file.stream.read(-1), chunk_info=dict(chunk_size=int(data.get('chunkSize')), chunk_number=int(data.get('chunkNumber')), total_size=int(data.get('totalSize'))), company_id=company.id, root_folder_id=company.journalist_folder_file_id, parent_folder_id=parent_id) file = youtube.upload() else: file = File.upload(name, data, parent.id, root, company, content=uploaded_file.stream.read(-1)) return jsonify({'result': {'size': 0}, 'error': True if file == 'error' else False, 'file_id': file})
def send(parent_id): """ YOU SHOULD SEND PROPERTY NAME, DESCRIPTION, ROOT_FOLDER AND FOLDER. NOW THIS VALUES GET FROM DB. HARDCODE!!! """ file = request.files['file'] parent = File.get(parent_id) root = parent.root_folder_id if parent.mime == 'root': root = parent.id data = request.form uploaded_file = request.files['file'] name = File.get_unique_name(uploaded_file.filename, data.get('ftype'), parent.id) company = db(Company, journalist_folder_file_id=root).one() if re.match('^video/.*', data.get('ftype')): body = {'title': file.filename, 'description': '', 'status': 'public'} youtube = YoutubeApi(body_dict=body, video_file=file.stream.read(-1), chunk_info=dict(chunk_size=int(data.get('chunkSize')), chunk_number=int(data.get('chunkNumber')), total_size=int(data.get('totalSize'))), company_id=company.id, root_folder_id=company.journalist_folder_file_id, parent_folder_id=parent_id) youtube.upload() else: File.upload(name, data, parent.id, root, content=uploaded_file.stream.read(-1)) return jsonify({'result': {'size': 0}})
def remove(json, file_id): file = File.get(file_id) ancestors = File.ancestors(file.parent_id) if not file or EmployeeHasRightAtCompany(RIGHT_AT_COMPANY.FILES_UPLOAD).check( company_id=utils.db.query_filter(Company, journalist_folder_file_id=ancestors[0]).first().id) is not True: return False return file.remove()
def cut(json): file = File.get(json['params']['id']) if not file or EmployeeHasRightAtCompany( RIGHT_AT_COMPANY.FILES_UPLOAD).check( company_id=get_company_from_folder( json['params']['folder_id']).id) is not True: return False return file.move_to(json['params']['folder_id'])
def set_properties(json): file = File.get(json['params']['id']) if not file or EmployeeHasRightAtCompany(RIGHT_AT_COMPANY.FILES_UPLOAD).check( company_id=get_company_from_folder(json['params']['root_id']).id) is not True: return False return File.set_properties(file, json['params']['add_all'], name=json['params']['name'], copyright_author_name=json['params']['author_name'], description=json['params']['description'])
def set_properties(json): file = File.get(request.json['params']['id'], ) return File.set_properties( file, request.json['params']['add_all'], name=request.json['params']['name'], copyright_author_name=request.json['params']['author_name'], description=request.json['params']['description'])
def set_properties(json): file = File.get(json['params']['id']) if not file or FilemanagerRights(company=get_company_from_folder(json['params']['id'])).action_is_allowed( FilemanagerRights.ACTIONS['UPLOAD']) != True: return False return File.set_properties(file, json['params']['add_all'], name=json['params']['name'], copyright_author_name=json['params']['author_name'], description=json['params']['description'])
def remove(json, file_id): file = File.get(file_id) ancestors = File.ancestors(file.parent_id) if not file or FilemanagerRights( company=db(Company, journalist_folder_file_id=ancestors[0]).first()).action_is_allowed( FilemanagerRights.ACTIONS['REMOVE'], file) != True: return False return file.remove()
def remove(json, file_id): file = File.get(file_id) ancestors = File.ancestors(file.parent_id) if not file or EmployeeHasRightAtCompany( RIGHT_AT_COMPANY.FILES_UPLOAD).check( company_id=utils.db.query_filter( Company, journalist_folder_file_id=ancestors[0]).first( ).id) is not True: return False return file.remove()
def set_properties(json): file = File.get(json['params']['id']) if not file or not File.if_action_allowed( 'upload', get_company_from_folder(json['params']['id']).id): return False return File.set_properties( file, json['params']['add_all'], name=json['params']['name'], copyright_author_name=json['params']['author_name'], description=json['params']['description'])
def set_properties(json): file = File.get(json['params']['id']) if not file or EmployeeHasRightAtCompany( RIGHT_AT_COMPANY.FILES_UPLOAD).check( company_id=get_company_from_folder( json['params']['root_id']).id) is not True: return False return File.set_properties( file, json['params']['add_all'], name=json['params']['name'], copyright_author_name=json['params']['author_name'], description=json['params']['description'])
def send(parent_id): parent = File.get(parent_id) root = parent.root_folder_id if parent.mime == 'root': root = parent.id company = utils.db.query_filter(Company, journalist_folder_file_id=root).one() if EmployeeHasRightAtCompany(RIGHT_AT_COMPANY.FILES_UPLOAD).check( company_id=company.id) is not True: return jsonify({'error': True}) data = request.form uploaded_file = request.files['file'] name = File.get_unique_name( urllib.parse.unquote(uploaded_file.filename).replace('"', '_').replace( '*', '_').replace('/', '_').replace('\\', '_'), data.get('ftype'), parent.id) data.get('ftype') if re.match('^video/.*', data.get('ftype')): body = { 'title': uploaded_file.filename, 'description': '', 'status': 'public' } youtube = YoutubeApi(body_dict=body, video_file=uploaded_file.stream.read(-1), chunk_info=dict( chunk_size=int(data.get('chunkSize')), chunk_number=int(data.get('chunkNumber')), total_size=int(data.get('totalSize'))), company_id=company.id, root_folder_id=company.journalist_folder_file_id, parent_folder_id=parent_id) file = youtube.upload() else: file = File.upload(name, data, parent.id, root, company, content=uploaded_file.stream.read(-1)) return jsonify({ 'result': { 'size': 0 }, 'error': True if file == 'error' else False, 'file_id': file })
def cut(json): file = File.get(request.json['params']['id']) return File.move_to(file, request.json['params']['folder_id'])
def copy(json): file = File.get(request.json['params']['id']) file.copy_file(request.json['params']['folder_id']) return file.id
def rename(json): file = File.get(request.json['params']['id'], ) return File.rename(file, request.json['params']['name'])
def cut(json): file = File.get(json['params']['id']) if not file or FilemanagerRights(company=get_company_from_folder(json['params']['id'])).action_is_allowed( FilemanagerRights.ACTIONS['UPLOAD']) != True: return False return file.move_to(json['params']['folder_id'])
def cropped(id): return render_template('cropped_image.html', image=File.get(id).url() )
def remove(json, file_id): file = File.get(file_id) ancestors = File.ancestors(file.parent_id) return file.remove(db(Company, journalist_folder_file_id=ancestors[0]).first().id)
def cut(json): file = File.get(json['params']['id']) if not file or EmployeeHasRightAtCompany(RIGHT_AT_COMPANY.FILES_UPLOAD).check( company_id=get_company_from_folder(json['params']['folder_id']).id) is not True: return False return file.move_to(json['params']['folder_id'])
def set_properties(json): file = File.get(request.json['params']['id'], ) return File.set_properties(file, request.json['params']['add_all'], name=request.json['params']['name'], copyright_author_name=request.json['params']['author_name'], description=request.json['params']['description'])
def test(): file = File.get('5644d72e-a269-4001-a5de-8c3194039273') name = File.set_properties(file,False,name='None', copyright_author_name='',description='') return render_template('tmp-test.html', file=name)