You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm receiving NRRD files over a network. I want to use pynrrd to parse and validate those files while they're in memory before they've been saved to disk.
I am passing in a file object to nrrd.read_data(). I want to keep using that file object afterwards but nrrd.read_data(_, file) closes the file. I can't reopen the file after passing it to nrrd.read_data() because I haven't yet persisted it to disk. Once the file has been closed, it's gone.
Minimal reproduction using Flask:
fromflaskimportFlask, requestimportnrrdapp=Flask(__name__)
@app.route("/process", methods=["POST"])defprocess_file():
file=request.files["file"].streamis_file_ok=check_nrrd(file)
ifnotis_file_ok:
return"some error", 400file.seek(0)
do_something_with_file(file)
return"uploaded"defcheck_nrrd(file):
"""Check that the NRRD conforms to our expectations"""header=nrrd.read_header(file)
data=nrrd.read_data(header, file)
# perform some checksfile_is_good= ...
returnfile_is_gooddefdo_something_with_file(file):
print(file.read())
I'm receiving NRRD files over a network. I want to use pynrrd to parse and validate those files while they're in memory before they've been saved to disk.
I am passing in a file object to
nrrd.read_data()
. I want to keep using that file object afterwards butnrrd.read_data(_, file)
closes the file. I can't reopen the file after passing it tonrrd.read_data()
because I haven't yet persisted it to disk. Once the file has been closed, it's gone.Minimal reproduction using Flask:
Tested with:
Log:
The text was updated successfully, but these errors were encountered: