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
Related
I am trying to build a bot using the BOT Framework that tells jokes when the user feels sad. I have scraped some data from a website and made an XML file. I have converted the XML file to JSON. I want the bot to extract data from this JSON file.
Is there any way to do it? Is there a way to add a file to the bot from which it extracts data. I tried building a bot using BOT composer. But could not find a way to extract data from a file or add a file to it.
What I understand is we can make HTTP requests. Should i build an API and then do it?
Is there a way to implement this using bot framework SDK in C#?
Please help. I am really stuck and cannot move forward.
Yes , you can write the custom action(API) to extract data from the file or If the JSON file you can directly read from the file( you can assgin to property to read the value ( Ref here how to read from the JSON file https://learn.microsoft.com/en-us/composer/tutorial/tutorial-get-weather?tabs=v2x ))
I have a created a file in my service (E:\User\example.pdf) and I want to convert that to blob in my controller to download the file using axios in my front-end.
How to do that? Thanks
As previous stated, won't hurt to check more on BLOB : https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction
Here is how to UPLOAD FILE TO BLOB: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet#upload-blobs-to-a-container
My project in .net core 2
I get base64string of file from web api, I Need this steps
Check string is valid file ?
Check file is image ? (optional)
get file format
get file size
save file in directory
I write this steps in php, But for c# .net core 2 i could not find the right functions
I am implementing a file upload mechanism using .net MVC, where the file upload is a html input with type file, I am using the controller to save to file, the param the controller receives is a httppostedfilebase.
My question is what is the best way to validate the file upload? there is lots out there on stackoverflow and the web saying its best to mime sniff and check the file extension etc I am looking for a modern way t do this.
What I do so far:
check file size
save away from web root
save as a different name
What is the best way to validate the type of file, e.g. doc/docx/pdf/rtf/txt to try and avid mime spoofing and malicious files?
I am trying to avoid a magic number approach too
I will be generating one pdf file where i have a location like http://www.example.com/ContextName/DefaultFolder..
where i need to save files in Default folder could you please help in in this.