Fix connections

This commit is contained in:
ashatora
2024-05-01 09:56:58 +03:00
parent 635e03be6d
commit 6a6ab2239c

View File

@@ -72,17 +72,19 @@ def upload_file(filename: str, key: str, bucket: str):
def pika_callback(ch, method, properties, body):
try:
data = json.loads(body)
params = data['params']
url = data['url']
files = []
for file in params['files']:
for file in data['files']:
fn = os.path.join(gettempdir(), uuid4().hex)
download_file(file['name'], file['bucket'], fn)
files.append(fn)
download_file(file['url']['name'], file['url']['bucket'], fn)
file['url'] = fn
files.append(file)
proxy = ServerProxy(url)
proxy.send(params, files, Config.ret_path)
finally:
ch.basic_ack(delivery_tag=method.delivery_tag)
@@ -173,8 +175,9 @@ def accept(params, files, url):
files_s3 = []
for file in params['files']:
fn = uuid4().hex
upload_file(file, fn, Config.s3_bucket)
files_s3.append({'name': fn, 'bucket': Config.s3_bucket})
upload_file(file['url'], fn, Config.s3_bucket)
file['url'] = {'name': fn, 'bucket': Config.s3_bucket}
files_s3.append(file)
data = {
'params': params,
'files': files_s3,
@@ -221,7 +224,7 @@ def xmlrpc_task():
app = FastAPI()
app.add_middleware(CORSMiddleware,
allow_origins=['http://10.10.8.24:3000'],
allow_origins=['http://10.10.8.79:3000'],
allow_credentials=True,
allow_methods=['*'],
allow_headers=['*']