ehossack / django-backblaze-b2

A storage backend for Django that uses Backblaze's B2 APIs
BSD 2-Clause "Simplified" License
27 stars 6 forks source link

Accessing files in private bucket #218

Closed blazstefin closed 6 days ago

blazstefin commented 2 months ago

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)
ehossack commented 2 months ago

Hi, sorry for the delay here, I'm mid vacation.

So if I'm understanding correctly, your goal is not only to access/expose private files, it is to generate signed urls? Signed URLS being the S3 feature, supported by the b2 compatible API?

In general, this library attempts to encapsulate b2 python sdk functionality, not s3 functionality.

I feel like I must be misunderstanding.

ehossack commented 1 month ago

Hi @blazstefin, haven't heard from you. If I don't hear back in a week or two, going to close this issue!