def upload_file(): if request.method == 'POST': # file = request.files['file'] # if file and allowed_file(file.filename): # filename = secure_filename(file.filename) # file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) # ## snippet to read code below # file.stream.seek(0) # seek to the beginning of file # myfile = file.file # will point to tempfile itself # dataframe = pd.read_csv(myfile) # ## end snippet user = auth.getLoggedInUser(request.headers['Authorization']) # check if the post request has the file part file = request.files.get('file') # if user does not select file, browser also # submit an empty part without filename if file.filename == '': flash('No file part') return exceptionHandler.InvalidUsage('Invalid Recording', status_code=420) if file and allowed_file(file.filename) and not mongoConnector.existInDatabase(file.filename): filename = uploader._safe_filename(file.filename) file.save('./' + filename) response = mongoConnector.pushToDatabase(filename, user['email'], user['permission']) return mongoConnector.prepareResponse(response) return '''
def upload_file(): if request.method == 'POST': # file = request.files['file'] # if file and allowed_file(file.filename): # filename = secure_filename(file.filename) # file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) # ## snippet to read code below # file.stream.seek(0) # seek to the beginning of file # myfile = file.file # will point to tempfile itself # dataframe = pd.read_csv(myfile) # ## end snippet user = auth.getLoggedInUser(request.headers['Authorization']) # check if the post request has the file part file = request.files['file'] # if user does not select file, browser also # submit an empty part without filename if file.filename == '': flash('No file part') return exceptionHandler.InvalidUsage('Invalid Recording', status_code=420) if file and allowed_file(file.filename) and not mongo.existInDatabase(file.filename): filename = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) response = mongo.pushToDatabase(filename, user['email'], user['permission']) return mongo.prepareResponse(response) return '''
def getMetaData(): user = auth.getLoggedInUser(request.headers['Authorization']) obj = { '$lookup': { 'from': 'powerFrequency', 'localField': 'gcsFileUrl', 'foreignField': 'gcsFileUrl', 'as': 'recordingsWithPowerData' } } userRecordingsWithPower = routesHandler.recordingsCollection.aggregate( [obj]) uRecords = [] sRecords = [] for obj in userRecordingsWithPower: if (obj['user'] == user and obj['permission'] == 'guest'): uRecords.append(obj) if (obj['permission'] == 'administrator'): sRecords.append(obj) latestComparison = routesHandler.comparisonCollection.find( {'user.email': user['email']}) metaData = { 'userRecordings': uRecords, 'sampleRecordings': sRecords, 'latestComparison': latestComparison } return prepareResponse(metaData)
def getMetaData(): user = auth.getLoggedInUser(request.headers['Authorization']) obj = { '$lookup': { 'from': 'powerFrequency', 'localField': 'stereoFilePath', 'foreignField': 'stereoFilePath', 'as': 'recordingsWithPowerData' } } userRecordingsWithPower = routes.recordingsCollection.aggregate([obj]) uRecords = [] sRecords = [] for obj in userRecordingsWithPower: if (obj['user'] == user and obj['permission'] == 'guest'): uRecords.append(obj) if (obj['permission'] == 'administrator'): sRecords.append(obj) latestComparison = routes.comparisonCollection.find({'user': user}) metaData = { 'userRecordings': uRecords, 'sampleRecordings': sRecords, 'latestComparison': latestComparison } return prepareResponse(metaData)
def getMyUserAudioFiles(): user = auth.getLoggedInUser(request.headers['Authorization']) return retrieveData.retrieveMyRecordings(user['email'])
def getUserAudioFiles(): user = auth.getLoggedInUser(request.headers['Authorization']) print(user['email']) return mongoConnector.retrieve(user['email'])
def getUserAudioFiles(): user = auth.getLoggedInUser(request.headers['Authorization']) print(user['email']) return mongo.retrieve(user['email'])