|
|
|
@ -57,18 +57,18 @@ class AzureContainer: |
|
|
|
|
ext = "hevc" if log_type.endswith('camera') else "bz2" |
|
|
|
|
return self.BASE_URL + f"{route_name.replace('|', '/')}/{segment_num}/{log_type}.{ext}" |
|
|
|
|
|
|
|
|
|
def upload_bytes(self, data: bytes | IO, blob_name: str) -> str: |
|
|
|
|
def upload_bytes(self, data: bytes | IO, blob_name: str, overwrite=False) -> str: |
|
|
|
|
from azure.storage.blob import BlobClient |
|
|
|
|
blob = BlobClient( |
|
|
|
|
account_url=self.ACCOUNT_URL, |
|
|
|
|
container_name=self.CONTAINER, |
|
|
|
|
blob_name=blob_name, |
|
|
|
|
credential=get_azure_credential(), |
|
|
|
|
overwrite=False, |
|
|
|
|
overwrite=overwrite, |
|
|
|
|
) |
|
|
|
|
blob.upload_blob(data) |
|
|
|
|
return self.BASE_URL + blob_name |
|
|
|
|
|
|
|
|
|
def upload_file(self, path: str | os.PathLike, blob_name: str) -> str: |
|
|
|
|
def upload_file(self, path: str | os.PathLike, blob_name: str, overwrite=False) -> str: |
|
|
|
|
with open(path, "rb") as f: |
|
|
|
|
return self.upload_bytes(f, blob_name) |
|
|
|
|
return self.upload_bytes(f, blob_name, overwrite) |
|
|
|
|