B2_Command_Line_Tool icon indicating copy to clipboard operation
B2_Command_Line_Tool copied to clipboard

Django storage integration

Open metakermit opened this issue 8 years ago • 2 comments

This is more of a question than an issue. I'm looking to maybe either patch or implement a new django-storages backend, because I'm having some problems with using the existing solutions:

  • https://github.com/royendgel/django-backblazeb2-storage
  • https://github.com/amlatyrngom/django-b2storage

(various 4xx errors in certain scenarios with not too informative error output, missing functionality like the public urls of files etc. to not get into too many details)

Now, the question – would you recommend using api.py as a stable officially supported B2 API wrapper that your team will keep in sync as the API changes? I see it provides some higher-level functionality like keeping track of the auth token expiry, a worker thread pool etc. that might make it nicer to integrate with e.g. a custom Django storage system. Or do you have another recommendation of how to integration B2 as a Django storage?

metakermit avatar Feb 21 '17 14:02 metakermit

Yes, that is what the B2Api and Bucket classes were made for.

You may want to use InMemoryAccountInfo instead of the default, which uses sqlite.

We guarantee forward compatibility in the same version, so your code written for b2 version x.y.z will also work with x.y.(z+k), for k>=0.

Bucket class can be extended by inheritance, for example to add cache.

Please link your repo if you are going to do this.

ppolewicz avatar Feb 21 '17 17:02 ppolewicz

OK, great. Thanks for the info!

For now I'm still weighing my options and trying to see if I can get the existing implementations to work (I just managed to get a patched version of django-backblazeb2-storage to support public urls in my personal project), so I'll try to observe how it behaves. Still, a longer term solution would for sure be based on B2Api from what you just told me. No point in trying to play cat and mouse over the public API if you're anyway supporting this Python API wrapper.

metakermit avatar Feb 21 '17 18:02 metakermit

You are very much recommended to use b2sdk directly, which has that apiver guarantee described by @ppolewicz .

As for Django storage backends, it seems there are now some decent implementations. In fact, thanks to Backblaze S3 compatibility, you should be able to use S3 API compatible implementations as well. A cursory google search returns: https://django-storages.readthedocs.io/en/latest/backends/backblaze-B2.html describing that approach , but one could find other as well. For quick comparison of different implementations, https://djangopackages.org/grids/g/storage-backends/ would be a good starting point.

mjurbanski-reef avatar Nov 10 '23 08:11 mjurbanski-reef