def upload_image(): f = request.files.get('upload') if not allowed_file(f.filename): return upload_fail('Image only!') f.save(os.path.join(current_app.config['BLUELOG_UPLOAD_PATH'], f.filename)) url = url_for('.get_image', filename=f.filename) return upload_success(url, f.filename)
def upload_image(): f = request.files.get('upload') if not allowed_file(f.filename): return upload_fail('Image only!') extend_name = '.' + f.filename.split('.')[-1] uniq_name = str(uuid.uuid4()) + extend_name f.save(os.path.join(current_app.config['BLUELOG_UPLOAD_PATH'], uniq_name)) url = url_for('.get_image', filename=uniq_name) return upload_success(url, uniq_name)
def upload_image(): f = request.files.get('upload') if not allowed_file(f.filename): return upload_fail('Image only!') postfix = f.filename.rsplit('.', 1)[1].lower() prefix = f.filename.rsplit('.', 1)[0].lower() current_time = str(time.strftime('%Y%m%d', time.localtime())) + "_" new_filename = current_time + str(hash(prefix)) + "." + postfix f.save( os.path.join(current_app.config['BLUELOG_UPLOAD_PATH'], new_filename)) url = url_for('.get_image', filename=new_filename) return upload_success(url, f.filename)