Uploading Large Files in ASP NET Core Web API - Performance Increase With Streams

  Рет қаралды 5,504

Code Maze

Code Maze

Күн бұрын

Пікірлер: 37
@CodeMaze
@CodeMaze 4 ай бұрын
Thank you all for watching and for your support. ►► If you want to master Web API development using best practices, check out our Web API book: bit.ly/3x75ZMM ►► Also, to build great full-stack apps with Blazor, check out our course: bit.ly/3Pw3Y33
@lachlanwilson6389
@lachlanwilson6389 2 ай бұрын
Works beautifully, thanks Marinko!
@CodeMaze
@CodeMaze 2 ай бұрын
You are very welcome. Thank you too for watchng the video and sharing your comment.
@jacksonmwangi1668
@jacksonmwangi1668 4 ай бұрын
@CodeMaze, thank you very much for this video, it couldn't have come at a better time
@CodeMaze
@CodeMaze 4 ай бұрын
You are most welcome. Thank you for watching it. I'm glad it helps.
@Mr.Pavel85
@Mr.Pavel85 4 ай бұрын
Thanks for the video, it's very nice solution! about a month or two ago I had to solve a similar problem and now I can compare both solutions :)
@CodeMaze
@CodeMaze 4 ай бұрын
I'm glad you like it. Thank you too for watching the video.
@PankajNikam
@PankajNikam 4 ай бұрын
Thanks for the video, use case of this can be like a video upload service like KZbin. Cool feature to add to this would be reporting real-time progress of the bytes uploaded to the consumer so that they can show a progress bar as to how much is remaining.
@CodeMaze
@CodeMaze 4 ай бұрын
Hi, thanks for watching the video. Your suggestion is great but I think that can be sorted out only on the client app. I have a video about file uploads with Angular and Web API. There, as far as I can remember, this logic is done only on the client side.
@PankajNikam
@PankajNikam 4 ай бұрын
@@CodeMaze I will have to watch that one to understand better. Thanks :)
@aweklin
@aweklin 4 ай бұрын
Great video as always!
@CodeMaze
@CodeMaze 4 ай бұрын
Glad you enjoyed! Thank you for watching it.
@MisterKoko668
@MisterKoko668 4 ай бұрын
Thank you for the video! In the slide you wrote "With byte[] or MemoryStream, the entire file is loaded into memory before processing" - but that's not the case for MemoryStream, that's a stream, isn't it?
@CodeMaze
@CodeMaze 4 ай бұрын
Hi. Well, MemoryStream != Stream. MemoryStream will create a stream whose backing store is memory. On the other hand Stream is the abstract base class of all streams. A stream is an abstraction of a sequence of bytes, such as a file, an input/output device, an inter-process communication pipe, or a TCP/IP socket. I used some definitions from official documentation but you see the difference.
@MisterKoko668
@MisterKoko668 4 ай бұрын
@@CodeMaze Thanks for your reponse! I had the idea that while the backing store is memory, it's still processed as a stream and hence still efficient and won't require loading all of it to memory at once.
@ManojRawat-lp4yc
@ManojRawat-lp4yc 23 күн бұрын
Why didn't you tried interface like IFormFile for uploading a file as use of stream can be done there as well ? Any particular reason for not choosing IFormFile ?
@CodeMaze
@CodeMaze 23 күн бұрын
No special reason, I just didn't need it here, and I can get the body from the request as shown in the video.
@kauavinicius9799
@kauavinicius9799 3 ай бұрын
That code did'nt work for me, i am getting 2 errors: System.IO.InvalidDataException: Multipart body length limit 16384 exceeded. and Unexpected end of Stream, the content may have already been read by another component. Can someone help me ?
@CodeMaze
@CodeMaze 3 ай бұрын
Well, that's pretty hard to say, why is that. It is even more awful to say it works for me, as you can see from the video :) But maybe try this thread: stackoverflow.com/questions/55582335/invaliddataexception-multipart-body-length-limit-16384-exceeded I really can't say what can be the issue. You are probably using my code in your custom solution and something is messing up inside the solution. I don't remember what was the size of that Zip file I used for testing, but it was a large one.
@harrisonwell1719
@harrisonwell1719 4 ай бұрын
If I need to retrieve a lot of images from the directory, Can I Cache them for faster retrieval?
@CodeMaze
@CodeMaze 4 ай бұрын
To be honest, I never had a situation where I had to return a lot of images, it was usually one or two related to the user's profile or product description or something like that, so I never done image caching. I see in ASP.NET Core apps like MVC or Razor you can use the UseStaticFiles method to do that, and I believe it can be done the same with Web API, but again, I really never done that.
@joysamuelkamlomo8684
@joysamuelkamlomo8684 4 ай бұрын
What about doing heavy complex calculations, data analysis stuff etc
@CodeMaze
@CodeMaze 4 ай бұрын
I am sorry, calculations and data analysis about what? I am just not sure I understand the comment and how it is related to this video.
@IZ908
@IZ908 Ай бұрын
It is not working for 2 gb files. HTTP Error 413.1 - Request Entity Too Large
@CodeMaze
@CodeMaze Ай бұрын
All the resources I found online regarding to this issue are referencing to the max allowed file size limit issue on the server you are using for hosting. So maybe those articles online can help.
@kurdishfreeman7568
@kurdishfreeman7568 3 ай бұрын
How can I post a file to this endpoint, using HttpClient?
@CodeMaze
@CodeMaze 3 ай бұрын
Hi. You can read this article where I use Blazor WASM with Web API to upload a file code-maze.com/blazor-webassembly-file-upload/
@gidolasajaye9238
@gidolasajaye9238 4 ай бұрын
do you have it in the book?
@CodeMaze
@CodeMaze 4 ай бұрын
You can always visit the sales page linked in the descritption window and you will find: "What's inside" section. There you can see the entire TOC from the book and some preview chapters.
@nicoxxxi
@nicoxxxi 4 ай бұрын
What is happening with your site? I am receiving some errors
@CodeMaze
@CodeMaze 4 ай бұрын
We had some cache issues, but now everything is back in order. Just hit CTRL+F5 on the page if you still see the issue.
@Miraziz-dotnet
@Miraziz-dotnet 4 ай бұрын
Or navigate to main page.
@davestorm6718
@davestorm6718 4 ай бұрын
I followed as much as I could, but getting System.InvalidOperationException: Unable to resolve service for type 'UploadingLargeFiles.Services.IFileService' while attempting to activate 'UploadingLargeFiles.Controllers.FileController'. at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ThrowHelperUnableToResolveService(Type type, Type requiredBy)
@davestorm6718
@davestorm6718 4 ай бұрын
oops! I didn't register the service: builder.Services.AddScoped();
@CodeMaze
@CodeMaze 4 ай бұрын
Hi, I just wanted to say this. When you get this type of error it always means there is something wrong with the service registration. Also, the source code is there - part of the patreon membership (for all the videos).
Audit Trail Implementation in ASP.NET Core Web API
10:39
Code Maze
Рет қаралды 3,2 М.
Logging With OpenTelemetry in ASP.NET Core Web API
17:36
Code Maze
Рет қаралды 2,1 М.
Can You Find Hulk's True Love? Real vs Fake Girlfriend Challenge | Roblox 3D
00:24
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
Implementing API Gateway With Ocelot in ASP.NET Core
13:26
Code Maze
Рет қаралды 6 М.
Background Jobs in ASP.NET Core
18:35
IAmTimCorey
Рет қаралды 57 М.
Car Management System: Complete GO Lang Project
4:40:00
Code Alley with Anurag
Рет қаралды 2,4 М.
Watch Out For THIS When Downloading Large Files in C#
13:31
Dev Leader
Рет қаралды 1,8 М.
Master Claims Transformation for Flexible JWT Auth in ASP.NET Core
14:10
Milan Jovanović
Рет қаралды 13 М.
Result Pattern Implementation in ASP NET Core Web API
13:28
Code Maze
Рет қаралды 5 М.
This tool annoyed me (so I built a free version)
19:38
Theo - t3․gg
Рет қаралды 194 М.
Implementing JWT Authentication in ASP.NET Core
23:51
Nick Chapsas
Рет қаралды 42 М.
Getting Started with OpenTelemetry in .NET
19:56
Nick Chapsas
Рет қаралды 66 М.
Swagger is Gone in .NET 9! Replace It With This.
9:34
Nick Chapsas
Рет қаралды 80 М.
Can You Find Hulk's True Love? Real vs Fake Girlfriend Challenge | Roblox 3D
00:24