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
Thanks for the video, use case of this can be like a video upload service like RUclips. 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.
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.
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?
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.
@@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.
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 ?
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 ?
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.
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.
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.
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.
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)
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).
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
Works beautifully, thanks Marinko!
You are very welcome. Thank you too for watchng the video and sharing your comment.
@CodeMaze, thank you very much for this video, it couldn't have come at a better time
You are most welcome. Thank you for watching it. I'm glad it helps.
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 :)
I'm glad you like it. Thank you too for watching the video.
Thanks for the video, use case of this can be like a video upload service like RUclips. 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.
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.
@@CodeMaze I will have to watch that one to understand better. Thanks :)
Great video as always!
Glad you enjoyed! Thank you for watching it.
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?
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.
@@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.
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 ?
No special reason, I just didn't need it here, and I can get the body from the request as shown in the video.
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 ?
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.
If I need to retrieve a lot of images from the directory, Can I Cache them for faster retrieval?
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.
What about doing heavy complex calculations, data analysis stuff etc
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.
It is not working for 2 gb files. HTTP Error 413.1 - Request Entity Too Large
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.
How can I post a file to this endpoint, using HttpClient?
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/
do you have it in the book?
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.
What is happening with your site? I am receiving some errors
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.
Or navigate to main page.
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)
oops! I didn't register the service:
builder.Services.AddScoped();
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).