diff --git a/mupifDB/api/main.py b/mupifDB/api/main.py index be985c6..48cd2dd 100644 --- a/mupifDB/api/main.py +++ b/mupifDB/api/main.py @@ -1,3 +1,5 @@ +import time + from fastapi import FastAPI, UploadFile, Depends from fastapi.responses import FileResponse, StreamingResponse from fastapi.responses import HTMLResponse @@ -469,11 +471,6 @@ def get_file(uid: str, tdir=Depends(get_temp_dir)): wfile = io.BytesIO(foundfile.read()) fn = foundfile.filename return StreamingResponse(wfile, headers={"Content-Disposition": "attachment; filename=" + fn}) - # fullpath = tdir + '/' + fn - # with open(fullpath, "wb") as f: - # f.write(wfile.read()) - # f.close() - # return FileResponse(path=fullpath, media_type='application/octet-stream', headers={"Content-Disposition": "attachment; filename=" + fn}) @app.post("/file/", tags=["Files"]) @@ -506,7 +503,7 @@ def get_property_array_data(fid: str, i_start: int, i_count: int): @app.get("/field_as_vtu/{fid}", tags=["Additional"]) -def get_property_array_data(fid: str, tdir=Depends(get_temp_dir)): +def get_field_as_vtu(fid: str, tdir=Depends(get_temp_dir)): pfile, fn = mupifDB.restApiControl.getBinaryFileByID(fid) full_path = tdir + "/file.h5" f = open(full_path, 'wb') diff --git a/mupifDB/workflowmanager.py b/mupifDB/workflowmanager.py index 4a5a23a..cd70a3a 100644 --- a/mupifDB/workflowmanager.py +++ b/mupifDB/workflowmanager.py @@ -933,9 +933,20 @@ def mapOutput(app, eid, name, obj_id, data_id, time, object_type, onto_path=None else: raise ValueError('Handling of io param of type %s not implemented' % object_type) - # elif object_type == 'mupif.PyroFile': - # prop = app.get(mupif.DataID[data_id], time, obj_id) - # restApiControl.setExecutionOutputObject(eid, name, obj_id, prop.to_db_dict()) + elif object_type == 'mupif.PyroFile': + pf = app.get(mupif.DataID[data_id], time, obj_id) + with tempfile.TemporaryDirectory(dir="/tmp", prefix='mupifDB') as tempDir: + fn = pf.getBasename() + full_path = tempDir + "/" + fn + mupif.PyroFile.copy(pf, full_path) + fileID = None + with open(full_path, 'rb') as f: + fileID = restApiControl.uploadBinaryFile(f) + f.close() + if fileID is not None: + restApiControl.setExecutionOutputObject(eid, name, obj_id, {'FileID': fileID}) + else: + print("PyroFile file was not saved") elif object_type == 'mupif.HeavyStruct': hs = app.get(mupif.DataID[data_id], time, obj_id) diff --git a/webapi/index.py b/webapi/index.py index 93f15b5..6d62fc7 100644 --- a/webapi/index.py +++ b/webapi/index.py @@ -412,7 +412,7 @@ def executions(): if 'filter_status' in args: filter_status = str(args['filter_status']) - html = '