Django Media Files - Restricting Uploadable File Types with Validators and python-magic

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024

Комментарии • 29

  • @SteveRobinson-n4k
    @SteveRobinson-n4k Месяц назад

    Fantastic video! So to be clear on one point: You switched from using an ImageField to a FileField in an earlier video in this series. If I use an ImageField instead, would I get validation functionality out of the box, or do I still have to use "install magic"? I was hoping to use a FileField as you have shown, but I can switch my code up if I am unable to deploy this solution into an Azure production environment.

  • @SOHAILKHAN-iu8fu
    @SOHAILKHAN-iu8fu Год назад +2

    Wow, this video is incredibly informative and eye-opening! I had no idea about these. Thank you so much for sharing and raising awareness on such an important topic. Keep up the great work!

    • @bugbytes3923
      @bugbytes3923  Год назад

      Thank you - I'm glad that the video was useful!

  • @seydinaoumarsamabaly1806
    @seydinaoumarsamabaly1806 Год назад +2

    Never disappointed with you mate. I learnt somethong new thank you Master 🙌🏾

  • @TomislavMiletic
    @TomislavMiletic Год назад

    Came back to post another comment, so i have implemented this but when trying to deploy to railway app, the build breaks on this python magic bin library. Any advice?
    Is there another way to do the same thing?

    • @bugbytes3923
      @bugbytes3923  Год назад

      Ah - sorry to hear that. Do you have an error log for this issue?
      I've not used Railway, but might be able to help.

  • @hjs9693
    @hjs9693 4 месяца назад

    Thank you for your video.
    im curious why just use 1024 bytes in from_buffer?
    Is this based on something that data or books?

    • @bugbytes3923
      @bugbytes3923  4 месяца назад

      Thank you. No real reason to choose that number, just for demo.

  • @ganiyevuz
    @ganiyevuz Год назад +3

    thanks this was useful for me 👍👍

  • @codedjango
    @codedjango Год назад +2

    This library is really magical 👍

  • @valentino7057
    @valentino7057 Год назад +2

    Exactly what I needed. Thanks man, you're the best!

  • @TomislavMiletic
    @TomislavMiletic Год назад

    One more great video, which is not a surprise, thank you! Can you please tell me, considering the options presented, is it enough to use only the 3rd option?

    • @bugbytes3923
      @bugbytes3923  Год назад

      Thank you!
      I would recommend all 3. Even adding the "accept" attribute in HTML can prevent unwanted uploads that will be rejected on your server. Anything to prevent unnecessary load on the server (plus associated costs) is a win!
      By only using the 3rd option, users will find it easier to upload the wrong file types, which the server then processes and rejects - that load can be avoided with the other two methods.

    • @TomislavMiletic
      @TomislavMiletic Год назад

      @@bugbytes3923 thank you

  • @Coden69
    @Coden69 Год назад +1

    Wowww

  • @digital-tree
    @digital-tree Год назад +1

    excellent video, congratulations on the didactics

  • @dodokwak
    @dodokwak Год назад

    Thx a lot.
    Small note about unit testing: if you used a generated file for the test you can get a TypeError (expect string but not imagefield file as 10:25 expects a path to the file. I've solved it by changing param to a file for reading bytes.

  • @HussainNazari-d7k
    @HussainNazari-d7k Год назад

    Thanks man ,very very good

  • @frameff9073
    @frameff9073 Год назад +2

    thank

  • @UchennaUdemezue-c2k
    @UchennaUdemezue-c2k Год назад

    Hey man I spent a week thinking on how best to do content validation of a file. This was very helpful, once step closer to completing the goal.

    • @bugbytes3923
      @bugbytes3923  Год назад

      Hey - thanks, glad to hear it was helpful. Thanks for watching! Good luck in your project.

  • @iwswordpress
    @iwswordpress 9 месяцев назад

    Excellent! My go to channel for Django :)

    • @bugbytes3923
      @bugbytes3923  9 месяцев назад

      Awesome - Thanks a lot for watching!