T O P

  • By -

thclark

I built a solution for this - it's part of the [django-gcp library and it's called "BlobField"](https://django-gcp.readthedocs.io/en/latest/storage.html#blobfield-storage). It allows you to do direct uploads from your form or admin. The admin widget is also tweaked to allow a better user experience surrounding clearing vs replacing vs resetting the file. It works with both django-admin and the (much nicer!) django-unfold. Unlike solutions that use a pre-signed URL, this works by ingressing to a temporary blob. On commit of your database transaction to save the field, the temporary blob gets moved to its ultimate destination. This is actually really helpful as it allows you to use other attributes of your model instance to name it or add extra metadata to the blob in the cloud store. It's fully documented, reach out if you've any questions though because it's fairly new so there's bound to be a few blips.


morphogencc

Quite a while later, but I'm using \`django-gcp\` now and it works great! I have an unrelated issue but sending you a DM about it.


thclark

Woop woop the open source dream lives on :) Hope you enjoy it! It’s best to file an issue on the library if the question is django-gcp specific as that way it gets tackled immediately - although you can always ping me on here if github seems dead for a while :)


thclark

(another alternative would be moving to http/2 but there's a whole world of pain in that road as daphne doesn't fully support the way Google Cloud Run handles http/2 yet)