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): """ 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 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): 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 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 = 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 })