fallbacks3 0.2.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fallbacks3
3
- Version: 0.2.0
3
+ Version: 0.4.0
4
4
  Summary: S3-compatible storage library with automatic fallback support
5
5
  Author-email: Mila de Oliveira <mila.oliveira@palver.com.br>
6
6
  Project-URL: Homepage, https://github.com/palverdata/fallbacks3
7
7
  Project-URL: Repository, https://github.com/palverdata/fallbacks3
8
8
  Project-URL: Issues, https://github.com/palverdata/fallbacks3/issues
9
- Requires-Python: >=3.9
9
+ Requires-Python: >=3.10
10
10
  Description-Content-Type: text/markdown
11
11
  Requires-Dist: boto3>=1.26.0
12
12
  Requires-Dist: pydantic-settings>=2.0.0
@@ -1,6 +1,12 @@
1
+ from __future__ import annotations
2
+
1
3
  from boto3 import client
4
+ from boto3.s3.transfer import TransferConfig
2
5
  from botocore.client import Config as BotoConfig
3
- from mypy_boto3_s3.client import S3Client
6
+ from typing import TYPE_CHECKING
7
+
8
+ if TYPE_CHECKING:
9
+ from mypy_boto3_s3.client import S3Client
4
10
 
5
11
 
6
12
  class S3Provider:
@@ -12,6 +18,7 @@ class S3Provider:
12
18
  endpoint: str,
13
19
  access_key_id: str,
14
20
  secret_access_key: str,
21
+ transfer_config: TransferConfig | None = None,
15
22
  ):
16
23
  """Initialize S3 provider with credentials.
17
24
 
@@ -20,9 +27,12 @@ class S3Provider:
20
27
  endpoint: S3 endpoint URL with scheme (e.g., 'https://ps3.palver.com')
21
28
  access_key_id: Access key ID
22
29
  secret_access_key: Secret access key
30
+ transfer_config: Optional boto3 TransferConfig for upload behaviour.
31
+ Defaults to boto3's built-in defaults when None.
23
32
  """
24
33
  self.provider_scheme: str = provider_scheme
25
34
  self.endpoint: str = endpoint
35
+ self.transfer_config: TransferConfig | None = transfer_config
26
36
  self.client: S3Client = client(
27
37
  "s3",
28
38
  config=BotoConfig(signature_version="s3v4"),
@@ -43,7 +53,11 @@ class S3Provider:
43
53
  Full URI of the uploaded file in format:
44
54
  <provider_scheme>://<bucket>/<file_name>
45
55
  """
46
- self.client.upload_file(file_path, bucket, file_name)
56
+ self.client.upload_file(
57
+ file_path, bucket, file_name, Config=self.transfer_config
58
+ ) if self.transfer_config else self.client.upload_file(
59
+ file_path, bucket, file_name
60
+ )
47
61
  return f"{self.provider_scheme}://{bucket}/{file_name}"
48
62
 
49
63
  def download_file(self, file_name: str, local_path: str, bucket: str) -> str:
@@ -1,4 +1,5 @@
1
1
  import asyncio
2
+
2
3
  from fallbacks3.config import config
3
4
  from fallbacks3.provider import S3Provider
4
5
  from fallbacks3.utils.uri import build_provider_credentials, parse_uri
@@ -12,6 +13,7 @@ class Storage:
12
13
  self,
13
14
  providers: str = config.providers,
14
15
  fallback_provider: str = config.fallback_provider,
16
+ provider_configs: dict[str, dict] | None = None,
15
17
  ):
16
18
  """Initialize storage with multiple providers.
17
19
 
@@ -23,6 +25,9 @@ class Storage:
23
25
  fallback_provider: Provider scheme to use for fallback (e.g., "r2").
24
26
  Must be one of the providers in the providers string.
25
27
  Defaults to FALLBACK_PROVIDER environment variable.
28
+ provider_configs: Optional per-provider kwargs keyed by provider scheme,
29
+ merged into the S3Provider constructor for the matching provider.
30
+ Example: {"mega": {"transfer_config": TransferConfig(...)}}
26
31
 
27
32
  Raises:
28
33
  ValueError: If fallback_provider not found in providers
@@ -39,6 +44,7 @@ class Storage:
39
44
  endpoint=creds.endpoint,
40
45
  access_key_id=creds.access_key,
41
46
  secret_access_key=creds.secret_key,
47
+ **(provider_configs or {}).get(creds.provider_scheme, {}),
42
48
  )
43
49
 
44
50
  self.fallback_provider: str = fallback_provider
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fallbacks3
3
- Version: 0.2.0
3
+ Version: 0.4.0
4
4
  Summary: S3-compatible storage library with automatic fallback support
5
5
  Author-email: Mila de Oliveira <mila.oliveira@palver.com.br>
6
6
  Project-URL: Homepage, https://github.com/palverdata/fallbacks3
7
7
  Project-URL: Repository, https://github.com/palverdata/fallbacks3
8
8
  Project-URL: Issues, https://github.com/palverdata/fallbacks3/issues
9
- Requires-Python: >=3.9
9
+ Requires-Python: >=3.10
10
10
  Description-Content-Type: text/markdown
11
11
  Requires-Dist: boto3>=1.26.0
12
12
  Requires-Dist: pydantic-settings>=2.0.0
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fallbacks3"
7
- version = "0.2.0"
7
+ version = "0.4.0"
8
8
  description = "S3-compatible storage library with automatic fallback support"
9
9
  readme = "README.md"
10
- requires-python = ">=3.9"
10
+ requires-python = ">=3.10"
11
11
  authors = [
12
12
  {name = "Mila de Oliveira", email = "mila.oliveira@palver.com.br"}
13
13
  ]
File without changes
File without changes