Skip to content

Commit

Permalink
rework code to take advantage of requests file streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
contrick64 committed Dec 18, 2024
1 parent f2141bb commit 94319e5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,18 @@ def set_basic_params(env_vars):
}
return params

def perform_post(api_url, params, files=None):
def perform_post(api_url, data, files=None):
logging.info("performing post")
try:
if files:
r = requests.post(api_url, data=params, files=files)
r = requests.post(api_url, data=data, files=files)
else:
r = requests.post(api_url, data=params)
r = requests.post(api_url, data=data)
except Exception as e:
logging.exception(f"error creating metadata object: {e}")
raise
if r.ok:
logging.debug("r is ok")
return r.json()["pid"]
else:
msg = f"error creating metadata object: {r.status_code} - {r.text}"
Expand Down Expand Up @@ -129,7 +130,7 @@ def ingest_files(
"file_name": file.name
})
params['content_streams'] = json.dumps(content_streams)
files[file.name] = file_obj
files['file'] = (file.name,file_obj)

logging.debug(f"{params=}")
logging.debug(f"{content_streams=}")
Expand Down

0 comments on commit 94319e5

Please sign in to comment.