Working With Images Like a Pro in .NET

  Рет қаралды 38,324

Nick Chapsas

Nick Chapsas

Күн бұрын

Enroll to "Cloud Fundamentals: AWS Services for C# Developers" for FREE: bit.ly/3XKUBOH
Become a Patreon and get source code access: / nickchapsas
Hello everybody I'm Nick and in this video I will show you how you can get started with uploading, retrieving or even editing images in C# and .NET. In order to store our images in a scalable way we will use AWS' S3 service which is excellent for this purpose.
To get $25 worth of free AWS credits email dotnet-on-aws-feedback[at]amazon[dot]com with the subject line "AWS CREDIT NICK CHAPSAS".
This video is sponsored by AWS
Don't forget to comment, like and subscribe :)
Social Media:
Follow me on GitHub: bit.ly/ChapsasG...
Follow me on Twitter: bit.ly/ChapsasT...
Connect on LinkedIn: bit.ly/ChapsasL...
Keep coding merch: keepcoding.shop
#csharp #dotnet #aws

Пікірлер: 53
@bloopers2967
@bloopers2967 Жыл бұрын
Can you do the same video with azure?
@456435ful
@456435ful Жыл бұрын
Uploading file to S3 directly from UI with a presigned Url is more like a pro.
@nickchapsas
@nickchapsas Жыл бұрын
Not as pro as straight FTP but ok
@mayogarcia5795
@mayogarcia5795 Жыл бұрын
​@@nickchapsas jajaja que bruto profe póngale 0 😂😂
@paveltsukanov4488
@paveltsukanov4488 Жыл бұрын
@@nickchapsas your example is good for small files, but programmers are lazy. They will take your example and use it for large files and then they will be frustrated and gobble up memory on the server. So you should always avoid uploading files through your server
@volppe01
@volppe01 Жыл бұрын
Exactly was our original sin years ago when uploading files and videos to azure do it through our own api instead of direct. So I would always recommended going the direct route.
@volppe01
@volppe01 Жыл бұрын
@@Downicon3 Sure there's a trade off. What we do is let our api backend handle the security and after the upload is finished it wlll also do all the post processing(we do a bit more the nick is showing in this video). We need to handle 100's of concurrent uploads at peak moments with some very large files so then the direct approach saves us a huge amount of money because wedo not need to handle that peak traffic through own api. Another improvement is that the whole process is just way faster when going direct instead of the indirect route.
@The00Rex
@The00Rex 9 ай бұрын
Just a heads up for someone that would struggle with the same thing: If you are having an issue when your function sometimes works, but only like 10% of the time, and you see 30 second timeout, for me it was caused by applying gaussian blurr with 25 weight. I have no idea why, I'm assuming free lambda functions get extremely little memory/cpu or something.
@Sanabalis
@Sanabalis Жыл бұрын
We are actually using something similar to trigger virus scanning on every uploaded object, except instead of modifying the objects, we're recording the object states into dynamo db. (could probably use s3 metadata as well, but we have some extra functionality with ddb)
@jimread2354
@jimread2354 Жыл бұрын
One of my favorite things about these videos is my new drinking game where you take a drink every time Nick says "and that is it!" 🍺🍺🍺😵‍💫😉
@tamaslencse3468
@tamaslencse3468 Жыл бұрын
When uploading the image you use profile_images/{id} as the key, and when you retrieve the image you use images/{id}. And it works! Am I missing something?
@The_ideal_optimum
@The_ideal_optimum Жыл бұрын
No minimal api?
@volinct
@volinct Жыл бұрын
1. Can AWS scan an uploaded file for viruses? 2. Is there an easy or standard way to check the content of a photo? Great video, thanks!
@w4.k
@w4.k Жыл бұрын
For the second part, AWS has a service called Rekognition
@idkanymoreman
@idkanymoreman Жыл бұрын
10:36 "I'm getting this face.. On the browser.." sounds like the ending of a horror movie 😁😁😁
@zabustifu
@zabustifu Жыл бұрын
11:34: silly question, why did pasting the code result in BucketName getting changed to _bucketName? Did I miss something? That caught my attention.
@Any1SL
@Any1SL Жыл бұрын
Your conroller is now coupled to the s3 objects. If you ever started using azure blob storage the controller should just have to swap the interface but now your implementation would need to update the controller
@nickchapsas
@nickchapsas Жыл бұрын
Like I said in the video, the only reason why I am "leaking" the IFormFile to the service is so you can see what properties from that object you need and then you can create a service object and decouple it.
@Any1SL
@Any1SL Жыл бұрын
@@nickchapsas i was referencing the s3 response objects and not the iformfile
@Any1SL
@Any1SL Жыл бұрын
@@XXnickles wrong. When building abstractions using interfaces if the consumers have to update their code then its a poor abstraction. I've learned this while collaborating with several principal engineers
@XXnickles
@XXnickles Жыл бұрын
@@Any1SL Something that I have learned the hard way is there is nothing as "a good abstraction", especially when dealing with IO. There is often a piece of data that is needed to wire the new dependency, and that triggers a change in the interface. You can argue than then you create adapters (pretty common "sorcery" used in these cases), but that is just add more dependencies and increase the complexity
@Any1SL
@Any1SL Жыл бұрын
@@XXnickles I've learned the hard way when creating the abstraction try and see if you could write 3 different implementations to see if it still works. And I agree you don't always get them right
@michaelakin766
@michaelakin766 Жыл бұрын
Nice, what would you have used to create a thumbnail for a pdf that was uploaded? I am not seeing many free options for that.
@ocnah
@ocnah Жыл бұрын
Did you ever take look at Thumbor?
@alonezlciel
@alonezlciel Жыл бұрын
I cannot endorse using specific cloud storage client in multi-cloud era.
@nickchapsas
@nickchapsas Жыл бұрын
Every cloud provider has the same triggering and serverless function processing logic so no matter which one you use or how many you choose to use, the logic is the same
@CRBarchager
@CRBarchager Жыл бұрын
5:15 Does AWS use Put and Post as the same? - What I can find (in REST APIs) Post is used to create new resources where Put is used to update existing resources but in your example you use Put for both.
@nickchapsas
@nickchapsas Жыл бұрын
It's not user as the same no. Put is used to upload and update an image. Don't use REST API principles as a guide for in any cloud provider. They don't build them as "true" REST but rather simple pragmetic HTTP APIs that might borrow some rest concepts here and there.
@mohamedal-qadeery6530
@mohamedal-qadeery6530 Жыл бұрын
is there discount for your api course?
@TheAzerue
@TheAzerue Жыл бұрын
hi i have one question. When saving image, we are uploading it twice browser -> server -> s3. So if there is a large file say 1gb, then technically we will be uploading 2 gb. Is there a better way to upload to s3 and avoid uploading file twice ?
@nickchapsas
@nickchapsas Жыл бұрын
You can prevent that by uploading from the client side directly to s3 using a presigned url
@parlor3115
@parlor3115 Жыл бұрын
@Nick What's the benefit of injecting services through an interface?
@isnakolah
@isnakolah Жыл бұрын
Decoupling the implentation from the service interface(dependency inversion). And mocking your tests as well, to name a few
@jackkendall6420
@jackkendall6420 Жыл бұрын
You can control what methods the injectee has access to without needing to change the actual class implementing the interface. E.g. if you already have an ImageEditor class that has fifteen different image-editing methods, but you want one specific API endpoint in your project to only have access to the CropImage method, you can make an IImageCropper interface with just that method. The ImageEditor class doesn't change, but you limit and control what functionality is available to the consumer of the interface. As for you would want to do that, look up the interface segregation principle
@andrewiecisa2907
@andrewiecisa2907 Жыл бұрын
Great video thanks. How about second part where you show how to generate thumbnail of a .docx uploaded or a .pdt?
@nickchapsas
@nickchapsas Жыл бұрын
Do you mean .pdf?
@guilhermeflores7564
@guilhermeflores7564 Жыл бұрын
I do this with puppeteer
@KyriakosStergiou
@KyriakosStergiou 3 ай бұрын
13:22 That's what she said
@michaelnjensen
@michaelnjensen Жыл бұрын
The ImageSharp license requirements are really offputting, either buy an expensive license or if you develop open-source stuff, only allow (A)GPL(3) compatibility. I'm personally steering clear of these half-open licenses, since I might later release stuff MIT or similar licensed code. Also AWS looks so much better than Azure we are stuck with a work, azure looks like a not even half polished turd in comparison, just getting Azure functions working, is a nightmare in itself, then you need to deal with the 100 edge cases where stuff just randomly stops working or doesnt trigger, because they try to run it as a web app in their whole special runtime.
@nickchapsas
@nickchapsas Жыл бұрын
ImageSharp has the "Transitive Package Dependency" clause though which basically renders the whole license pointless.
@lambda42
@lambda42 Жыл бұрын
As a corporate developer, where we easily qualify for >1M revenue, but where the software development is 0.001% of our business, things just become a real nightmare to deal with, compared to plain MIT/BSD/Apache 2.0 licensed libraries. It's not that we just want to "exploit" free/open-source code, we actually released several MIT-licensed projects ourselves. It's the classic, but then you should just pay $5000/y, but since the software development part is such a small part of our company, that recurring expense would never be approved, so the only alternative is finding some other library, or writing it ourselves for the 2% of the features we would have needed from ImageSharp in this example. As an open-source developer in my spare time, this hurts since we all know it's hard to get funding. But from a business perspective, ImageSharp is just a $5000/y image library, that just happens to have sources available, with some weird license quirks. Doing corporate development just sucks, you can spend all the money you need on IDEs, cloud infrastructure, and stuff like that, but actually buying licenses for libraries is seen as a nogo by management. So let's say we as a company release a project licensed as MIT, that uses ImageSharp, who is liable for what costs, the end user, us as developers, even when the result is open-source, but just happens to be MIT licensed which isn't AGPL/GPL3, it's too many questions, and just not worth the trouble, if there is an MIT library available that does 95% of what we need, then it's more feasible to just contribute the remaining 5% back, and use that instead.
@kalpeshblue2
@kalpeshblue2 Жыл бұрын
I feel title of the video was a click bait.
@nickchapsas
@nickchapsas Жыл бұрын
Why do you feel that way? Both the title and the thumbnail tell you what this video is about. It's about uploading, retrieving and resizing images, in a very cool way. What's the clickbait about?
@kalpeshblue2
@kalpeshblue2 Жыл бұрын
@@nickchapsas I feel the title must have mentioned “using AWS” because not every one is using AWS. And resize feature is dependent on cloud. So same not everyone is using cloud. Else video is very good.
@nickchapsas
@nickchapsas Жыл бұрын
@@kalpeshblue2 I mean, I could add "using the cloud" but the same thing can work outside of the cloud with the exact same logic. You can set a directory monitor that triggers a console app every time an image is uploaded and do the same thing. There is so much you can add in the title before it gets cropped so even if I added that part, it wouldn't actually be shown when the video is listed. It's a tricky one
@michaelakin766
@michaelakin766 Жыл бұрын
@@kalpeshblue2 I agree with Nick below. You could do the same thing without the cloud with a directory monitor service, or in the api when you upload the file.
@darkmatter8650
@darkmatter8650 Жыл бұрын
Hey.. Nick.. I am editing a PDF on PDF candy website... It takes an hour to load PDF and it's painfully slow.. Like after editing a sentence cursor rests a while.. Sometimes page jumps automatically in wrong direction. After editing PDF size should be smaller.. It gets bigger. Kept auto/smooh scrolling checked/unchecked...no hope. Now a days it's showing a script may be busy on this site.. Warning unresponsive script error. In the corner it shows Javscript (0).Safe mode is useless. All happening in Firefox. Chrome gives memory error Aw snap. Can I have your mail address? So you check on it with my PDF? Please reply soon.
@seanjonas5024
@seanjonas5024 Жыл бұрын
Hi
@csabraxas
@csabraxas Жыл бұрын
hi
@JoachimMalling
@JoachimMalling Жыл бұрын
First!
@saberint
@saberint Жыл бұрын
Argh… I can’t give a thumbs up because you flogging AWS :(
@Grigorii-j7z
@Grigorii-j7z Жыл бұрын
Nah. Give me C++ assemblies and Com Surogate for images every day over managed languages
@Grigorii-j7z
@Grigorii-j7z Жыл бұрын
@@fusedqyou Cause Nick's videos are pretty entertaining and helpful when it comes to new features or techniques overview.
3 .NET "Best Practices" I Changed My Mind About
10:16
Nick Chapsas
Рет қаралды 103 М.
Build Clean Messaging in .NET with MassTransit
21:44
Nick Chapsas
Рет қаралды 99 М.
WORLD BEST MAGIC SECRETS
00:50
MasomkaMagic
Рет қаралды 49 МЛН
Apple peeling hack @scottsreality
00:37
_vector_
Рет қаралды 128 МЛН
NativeAOT for .NET APIs Is Here and It’s INSANE!
14:07
Nick Chapsas
Рет қаралды 87 М.
Testing in .NET is About to Change
12:54
Nick Chapsas
Рет қаралды 49 М.
40 APIs Every Developer Should Use (in 12 minutes)
12:23
Coding with Lewis
Рет қаралды 367 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 189 М.
Don't Use Polly in .NET Directly. Use this instead!
14:58
Nick Chapsas
Рет қаралды 62 М.
THIS BOT RATED IMPOSSIBLE!?!?!
28:37
GMHikaru
Рет қаралды 341 М.
Stop Using FirstOrDefault in .NET! | Code Cop #021
12:54
Nick Chapsas
Рет қаралды 60 М.
We stopped using serverless. The results are insane.
18:27
Theo - t3․gg
Рет қаралды 101 М.
The Logging Everyone Should Be Using in .NET
15:34
Nick Chapsas
Рет қаралды 68 М.
Background Tasks Are Finally Fixed in .NET 8
10:29
Nick Chapsas
Рет қаралды 110 М.
WORLD BEST MAGIC SECRETS
00:50
MasomkaMagic
Рет қаралды 49 МЛН