Working With Images Like a Pro in .NET

Sdílet
Vložit
  • čas přidán 7. 05. 2023
  • 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/ChapsasGitHub
    Follow me on Twitter: bit.ly/ChapsasTwitter
    Connect on LinkedIn: bit.ly/ChapsasLinkedIn
    Keep coding merch: keepcoding.shop
    #csharp #dotnet #aws

Komentáře • 56

  • @bloopers2967
    @bloopers2967 Před rokem +16

    Can you do the same video with azure?

  • @456435ful
    @456435ful Před rokem +12

    Uploading file to S3 directly from UI with a presigned Url is more like a pro.

    • @nickchapsas
      @nickchapsas  Před rokem +6

      Not as pro as straight FTP but ok

    • @mayogarcia5795
      @mayogarcia5795 Před rokem

      ​@@nickchapsas jajaja que bruto profe póngale 0 😂😂

    • @paveltsukanov4488
      @paveltsukanov4488 Před rokem +3

      @@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 Před rokem

      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 Před rokem +4

      @@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 Před 6 měsíci +2

    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 Před rokem +2

    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)

  • @tamaslencse3468
    @tamaslencse3468 Před rokem +1

    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?

  • @jimread2354
    @jimread2354 Před rokem +1

    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!" 🍺🍺🍺😵‍💫😉

  • @michaelakin766
    @michaelakin766 Před rokem

    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.

  • @volinct
    @volinct Před rokem +4

    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 Před rokem

      For the second part, AWS has a service called Rekognition

  • @vangelisboltsis7901
    @vangelisboltsis7901 Před rokem +1

    Thanks Nick! P.S. I expected a minimal API implementation instead of a controller since you are leading the way for minimal APIs

    • @nickchapsas
      @nickchapsas  Před rokem +4

      I tend to still use Controllers for videos instead of Minimal APIs to keep the video content "familiar". With the release of .NET 8, I will be switching to using Minimal APIs only

    • @kazepis
      @kazepis Před rokem +1

      @@nickchapsas can we also have a video about the customization of your terminal?

  • @idkanymoreman
    @idkanymoreman Před rokem

    10:36 "I'm getting this face.. On the browser.." sounds like the ending of a horror movie 😁😁😁

  • @The_ideal_optimum
    @The_ideal_optimum Před rokem +1

    No minimal api?

  • @CRBarchager
    @CRBarchager Před rokem

    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  Před rokem +5

      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.

  • @zabustifu
    @zabustifu Před rokem

    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 Před rokem +4

    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  Před rokem

      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 Před rokem +1

      @@nickchapsas i was referencing the s3 response objects and not the iformfile

    • @Any1SL
      @Any1SL Před rokem

      @@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 Před rokem

      @@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 Před rokem

      @@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

  • @TheAzerue
    @TheAzerue Před rokem

    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  Před rokem

      You can prevent that by uploading from the client side directly to s3 using a presigned url

  • @andrewiecisa2907
    @andrewiecisa2907 Před rokem

    Great video thanks. How about second part where you show how to generate thumbnail of a .docx uploaded or a .pdt?

  • @ocnah
    @ocnah Před rokem

    Did you ever take look at Thumbor?

  • @mohamedal-qadeery6530

    is there discount for your api course?

  • @alonezlciel
    @alonezlciel Před rokem +2

    I cannot endorse using specific cloud storage client in multi-cloud era.

    • @nickchapsas
      @nickchapsas  Před rokem

      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

  • @parlor3115
    @parlor3115 Před rokem

    @Nick What's the benefit of injecting services through an interface?

    • @isnakolah
      @isnakolah Před rokem +1

      Decoupling the implentation from the service interface(dependency inversion). And mocking your tests as well, to name a few

    • @jackkendall6420
      @jackkendall6420 Před rokem +1

      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

  • @michaelnjensen
    @michaelnjensen Před rokem +1

    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  Před rokem

      ImageSharp has the "Transitive Package Dependency" clause though which basically renders the whole license pointless.

    • @lambda42
      @lambda42 Před rokem +2

      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.

  • @KyriakosStergiou
    @KyriakosStergiou Před 15 dny

    13:22 That's what she said

  • @darkmatter8650
    @darkmatter8650 Před rokem

    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 Před rokem

    Hi

  • @csabraxas
    @csabraxas Před rokem

    hi

  • @kalpeshblue2
    @kalpeshblue2 Před rokem +1

    I feel title of the video was a click bait.

    • @nickchapsas
      @nickchapsas  Před rokem

      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 Před rokem +1

      @@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  Před rokem +1

      @@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 Před rokem

      @@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.

  • @JoachimMalling
    @JoachimMalling Před rokem

    First!

  • @saberint
    @saberint Před rokem

    Argh… I can’t give a thumbs up because you flogging AWS :(

  • @user-hb7py7xy7b
    @user-hb7py7xy7b Před rokem

    Nah. Give me C++ assemblies and Com Surogate for images every day over managed languages

    • @user-hb7py7xy7b
      @user-hb7py7xy7b Před rokem

      @@fusedqyou Cause Nick's videos are pretty entertaining and helpful when it comes to new features or techniques overview.