0

I have an asp net core web application where I can upload files, and on the controller I get the files in IFormFile like this:

public IActionResult Create (AcquisitionDto <IFormFile> acquisitionDto)

Some of these files are images, but one is a .h5 with metadata. And I want to store this information in mongdb, so far so good.

But before writing to mongodb, I want to extract the information inside h5 so I can save it as fields in the mongo document. In short, I want to open the .h5 file I get in controler as IFormFile and convert its content to JSON.

I am using HDF5DotNet.x64 package to try to open the file, but I can only open .h5 if I pass the file path but cannot open from a byte[] or MemoryStream.

Do you know any way or package to do this?

Thank you very much

supremus
  • 11
  • 2
  • The title asks one thing, and half of the question another. Is the *actual* question whether HDF5DotNet can work with streams? – Panagiotis Kanavos Nov 22 '19 at 13:06
  • BTW HDF5 is meant to handle a *LOT* of data, too much to go into a JSON file. It's meant for quick access to only parts of the file without having to load the entire file or even scan it to get to a specific point. There's probably little use for loading data from a stream. Keeping the entire uploaded file in memory may be impossible too. Why not just store it in a temp folder and read the data you want from there? – Panagiotis Kanavos Nov 22 '19 at 13:11
  • Hi @PanagiotisKanavos , I did not consider saving to a local folder because the application is distributed in containers,and as I have the file in memory after the user uploads it would be cleaner not to use folders. – supremus Nov 22 '19 at 14:35
  • And containers *do* store state in mounted folders. Temporary files can be stored *inside* the container without a problem. They'll be deleted when the container shuts down. In your case, that's not a problem. The important fact though is that HDF5 works with *huge* data (TB-sized) that can't be kept in memory. – Panagiotis Kanavos Nov 22 '19 at 14:41
  • Yes, it makes sense. I just want to expose some properties when saving to mongo so I can make queries without opening the file. Maybe follow your advice. Thank you very much – supremus Nov 22 '19 at 17:06

0 Answers0