django-backblaze-b2 icon indicating copy to clipboard operation
django-backblaze-b2 copied to clipboard

Accessing files in private bucket

Open blazstefin opened this issue 6 months ago • 2 comments

I have an issue with accessing files form private bucket. I managed to setup working uploads but i cannot figure out on how to generate signed urls.

This is my setup

class StaticStorage(BackblazeB2Storage):
    def __init__(self, *args, **kwargs):
        kwargs["application_key_id"] = settings.BACKBLAZE_CONFIG["application_key_id"]
        kwargs["application_key"] = settings.BACKBLAZE_CONFIG["application_key"]
        kwargs["bucket"] = "static-prod"
        super().__init__(*args, **kwargs)


class MediaStorage(BackblazeB2Storage):
    def __init__(self, *args, **kwargs):
        kwargs["application_key_id"] = settings.BACKBLAZE_CONFIG["application_key_id"]
        kwargs["application_key"] = settings.BACKBLAZE_CONFIG["application_key"]
        kwargs["bucket"] = "media-prod"
        super().__init__(*args, **kwargs)
  @property
  def streaming_url(self):
      if settings.DEBUG:
          return self.master_playlist_url
      else:
          return default_storage.url(self.master_playlist_url)

  @property
  def thumbnail_url(self):
      if settings.DEBUG:
          return self.thumbnail.url
      else:
          return default_storage.url(self.thumbnail.name)

blazstefin avatar Aug 12 '24 16:08 blazstefin