Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add validators to BlobField #61

Open
3 of 5 tasks
morphogencc opened this issue Mar 7, 2024 · 1 comment
Open
3 of 5 tasks

How to add validators to BlobField #61

morphogencc opened this issue Mar 7, 2024 · 1 comment

Comments

@morphogencc
Copy link

Support request

About me

Hello! I'm using django to make the backend for science museum installations. I use django to manage data, allow museum staff to make updates to multimedia on the museum floor, and ultimately provide the backend for visitor-facing multimedia experiences.

Request

  • I've searched the list of existing issues
  • I expected the docs to cover it in this section but they don't cover it.

I'm trying to identify how I can add validators to BlobField for GCP storage. I'd love to be able to validate file types and, if the underlying data is multimedia, check image or video dimensions. The documentation doesn't make it clear how I could control what type of Blobs are uploaded.

Supporting Octue

Octue is an Open-Source Software organisation helping you and many others to fight climate change. Providing support for your issues costs us c. 500GBP/day. Might your organisation be in a position to help sponsor this issue?

  • We already are (eg via technical partnership or GitHub Sponsors )
  • Yes (we'll prioritise this issue, and be in touch)
  • No (we'll work on this issue as and when it aligns with our core development activity)
@thclark
Copy link
Contributor

thclark commented Mar 14, 2024

Hi @morphogencc - welcome and thnaks for using dajngo-gcp. I love that the science museum is getting value out of it!

I think it should be possible to achieve what you're looking for by restricting the accept attribute on the file upload widget, and thus rather than creating a validation error, simply prevent upload of file types.

I looked into this when building, and as I recollect, it was possible.

More tricky is extraction of metadata from the files, particularly checking size information and the like. If you need to open and process file contents to get that data, we'd need to think hard about the pattern of how to do that without filling your server with video processing code! This might be a good use case for a background worker task or lambda function that adds metadata to the object itself.

A couple of other questions:

  • Are you using BlobField via the admin, or via your own frontend?
  • Do you have clear sets of allowable file types?

If you're still opening to sponsor us closing the issue, may I suggest you book a quick meeting on calendly (we'd only need 30 minutes) and we'll have a look together.

Best,

Tom

@thclark thclark pinned this issue Mar 14, 2024
@thclark thclark unpinned this issue Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants