mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 10:45:21 +03:00
Add support for unsigned connections to S3 client when endpoint URL starts with 'http://' in StorageS3 constructor
This commit is contained in:
parent
5f4a107e8e
commit
f60af0f212
@ -5,6 +5,9 @@ from pathlib import Path
|
|||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
import boto3
|
import boto3
|
||||||
|
from botocore import UNSIGNED
|
||||||
|
from botocore.config import Config
|
||||||
|
from botocore.session import Session as boto_session
|
||||||
from peewee import fn
|
from peewee import fn
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
@ -24,12 +27,29 @@ class StorageS3:
|
|||||||
def __init__(self, config: FrigateConfig) -> None:
|
def __init__(self, config: FrigateConfig) -> None:
|
||||||
self.config = config
|
self.config = config
|
||||||
if self.config.storage.s3.enabled:
|
if self.config.storage.s3.enabled:
|
||||||
self.s3_client = boto3.client(
|
if self.config.storage.s3.endpoint_url.startswith('http://'):
|
||||||
"s3",
|
session = boto_session()
|
||||||
aws_access_key_id=self.config.storage.s3.access_key_id,
|
session.set_config_variable('s3',
|
||||||
aws_secret_access_key=self.config.storage.s3.secret_access_key,
|
{
|
||||||
endpoint_url=self.config.storage.s3.endpoint_url,
|
'use_ssl': False,
|
||||||
)
|
'verify': False,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.s3_client = session.create_client(
|
||||||
|
"s3",
|
||||||
|
aws_access_key_id=self.config.storage.s3.access_key_id,
|
||||||
|
aws_secret_access_key=self.config.storage.s3.secret_access_key,
|
||||||
|
endpoint_url=self.config.storage.s3.endpoint_url,
|
||||||
|
config=Config(signature_version=UNSIGNED)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.s3_client = boto3.client(
|
||||||
|
"s3",
|
||||||
|
aws_access_key_id=self.config.storage.s3.access_key_id,
|
||||||
|
aws_secret_access_key=self.config.storage.s3.secret_access_key,
|
||||||
|
endpoint_url=self.config.storage.s3.endpoint_url,
|
||||||
|
)
|
||||||
|
|
||||||
self.s3_bucket = self.config.storage.s3.bucket_name
|
self.s3_bucket = self.config.storage.s3.bucket_name
|
||||||
self.s3_path = self.config.storage.s3.path
|
self.s3_path = self.config.storage.s3.path
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user