def POST(self, format): cgi.maxlen = settings.MAX_UP_FILE_SIZE if not format: format = '.json' input = web.input(file={}) if input.file.file: if not is_mp3(input.file.file): return simplejson.dumps({ 'code': 1, 'error': 'Check file format and try again' }) try: info = get_mp3_info(input.file.file) info['FILENAME'] = input.file.filename except: return simplejson.dumps({ 'code': 2, 'error': 'Error getting file information' }) id = storage.save(info, input.file.file, db.master) search.update(id, info) return simplejson.dumps({'code': 0})
def POST(self): cgi.maxlen = settings.MAX_UP_FILE_SIZE input = web.input(file={}) if input.file.file: if not is_mp3(input.file.file): raise web.seeother('/upload/error') try: info = get_mp3_info(input.file.file) info['FILENAME'] = input.file.filename except: raise web.seeother('/upload/error') id = storage.save(info, input.file.file, db.master) search.update(id, info) raise web.seeother('/')
def POST(self, format): cgi.maxlen = settings.MAX_UP_FILE_SIZE if not format: format = '.json' input = web.input(file={}) if input.file.file: if not is_mp3(input.file.file): return simplejson.dumps({'code':1, 'error':'Check file format and try again'}) try: info = get_mp3_info(input.file.file) info['FILENAME'] = input.file.filename except: return simplejson.dumps({'code':2, 'error':'Error getting file information'}) id = storage.save(info, input.file.file, db.master) search.update(id, info) return simplejson.dumps({'code':0})