How to read very large files (More than 2GB) from ASP.NET Web API Controller - asp.net-web-api

I have a very large file (more than 2GB Size) stored in some folder in disk. I want to read the contents of this file in my MVC Web application using HttpClient. How should I return the contents of large file from ASP.NET Web API (based on .Net Framework 4.8) controller and consume it using HttpClient without memory issues?
Any help would be appreciated?
I have read many blogs over web but in vain.

Related

Can I just create a simple website project in VS without the .NET stuff?

I would like to split my .NET Core web application into multiple layers:
UI
API
Logic/Domain
Data
...
All of them seem clear enough apart from (1). Is it possible to create a simple web site which consumes the API layer? When I mean simple I mean that I do not think it needs .NET Core, just client side libraries such as Bootstrap/Angular.
I can create a simple project like this outside of VS easily, but I want it as part of my project, when I go to New Project all I see is:
What is the correct approach to take here?

Caching for both Angular and ASP .NET MVC

Background
In my project app, many small applications has been integrated and they have built-in different technologies such as
Angular JS 1.5
ASP.Net MVC
Angular 5
My app also uses AWS as cloud partner.
Problem
I need to implement Caching mechanism in my app. I am storing some values in S3 bucket and I am using API calls to pull the values. I want to keep those values in Cache. Since, it is implemented in multiple technologies (especially Angular and ASP.Net MVC), Does any caching mechanism can be used in common?
Observations
I have done some work on this and observed the following caching is available
.NET MVC - In Memory Caching
Angular - In Memory Cache with ReactJS
As AWS is my Cloud Partner, it is offering ElastiCache as a Web service, which supports MemCached and Redis. I am not clear whether this will behave like normal In-Memory Cache ( in ASP .NET Core) or this will refer database for caching and retrieve details (cause round-trip!) from there?
Question
Can anyone let me know best caching technique can be handled to my app for both .net mvc and angular?
This is bit tricky (I am assuming that you are using multiple servers of memcache). When you use memcache a lot depends on the clients implementation. Your client decides, on which server a particular key will be stored. And the servers are unaware of the existences of the other servers.
As you are using different languages you will be using different clients so each client will be implementing its own algorithm to decide the server on which the key will be placed. So there will be cases where your client on Angular will store key "K1" on server "S1" and the .Net Client will store the same key on server "S2"
This will add another problem of invalidating these keys, as it will be needed to invalidate the key on both servers.
There is one more problem. You will have to store all objects in a json format if the keys are common. So that the keys is stored on the same memcache server will be read by all programing languages.
I think the best thing is to set a small enough time to invalidate keys on memcache (if it is feasible) and storing keys with different prefix or suffix for each client type. So .net client will store key K1 as 'K1-net' and the one with Angular will store it as "k1-ang".
I would also explore redis which might help (not sure)

Need an example for using RavenFS with WebAPI

Trying to implement an artifact store for archiving thousands of large/small files for work. Building a POC using .NET WebAPI with RavenFS to store files.
As a newbie to RavenFS, looking for an example which will help me to redirect large files streams uploaded to REST api to RavenFS without storing them on the web server. While searching found a thread on mutipartformdatastreamprovider and memory stream providers. Can someone share an example how to use it with RanvenFS?

Handling image content in gae web application

I am building a new web application. I use google appengine , jsf2, primefaces , java technologies for building this web application. I have to build a dynamic image gallery within this web application. ie registered users should be able to load images to a gallery and then it should be available for viewing by the public.
My issue is that :
1) app engine allows only a maximum of 1mb file to be written to its blob store at a time.
2) app engine doesn't allow to write to the server file system.
3) Should I store each image as a blob to the gae database?. But if I do that the whole application will be damn slow as there can be a lot of images. So reading the images from the blob store can make it slow and will cost heaps of processing power.
Am really confused about a proper solution and couldn't find any proper recommendation in the web. I am pretty sure that there will be a descent solution available !
It would be a great help if some one with prior experience in building web application's which deals with a lot of image content could advice me a good solution.
The solution is to use upload URLs when users are uploading images, so that they get uploaded directly to the Blobstore:
https://developers.google.com/appengine/docs/java/blobstore/#Java_Uploading_a_blob
Then just reference the blobs directly via getServingUrl() rather than having your application try to read them into memory.
You really should use GCS (Google Cloud Storage), and not the blobstore. The call from a users browser to an image stored in GCS goes directly to there, and is not charged to your app.

Track API usage in ASP.NET MVC during development and/or production

My app makes requests to
http://www.brewerydb.com/api/breweries/?apikey=<key>&<parameters>
but I'm only given 100 requests per hour. I considered recording request instances in the app's database but during development I am often regenerating the database using code the Entity Framework 4.1 so that doesn't seem like it would work. Any ideas?
Some kind of database would be best.
If your regenerating the DB as you say, then store it in a different DB, or if you simply want to store basic info (date/time of hit), then nothing wrong with using XML or even a CSV file on your web server.

Resources