bigbucket-sdk 0.1.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.
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: bigbucket-sdk
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for BigBucket - media storage, Sharp image optimization, and global CDN delivery for Flask, FastAPI, and Django.
5
+ Author: BigBucket Team
6
+ License: MIT
7
+ Keywords: bigbucket,image-storage,image-upload,cdn,r2,fastapi,flask,django,sdk
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Internet :: WWW/HTTP
18
+ Classifier: Topic :: Multimedia :: Graphics
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: httpx>=0.25.0
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
25
+
26
+ # bigbucket-sdk
27
+
28
+ Official Python SDK for [BigBucket](https://github.com/bigbucket/bigbucket) — developer-first media storage, on-the-fly Sharp image transformations, and Cloudflare R2 CDN delivery for **FastAPI**, **Flask**, and **Django**.
29
+
30
+ ---
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install bigbucket-sdk
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Quickstart
41
+
42
+ Set your API key in environment variables:
43
+
44
+ ```bash
45
+ BIGBUCKET_API_KEY=bb_sec_your_secret_api_key_here
46
+ # BIGBUCKET_API_URL=http://localhost:8000/api/v1
47
+ ```
48
+
49
+ Upload an image and generate a resized WebP CDN URL:
50
+
51
+ ```python
52
+ import os
53
+ from bigbucket import BigBucket
54
+
55
+ client = BigBucket(api_key=os.environ["BIGBUCKET_API_KEY"])
56
+
57
+ with open("./shoe.jpg", "rb") as f:
58
+ asset = client.upload(f, filename="shoe.jpg", content_type="image/jpeg")
59
+
60
+ print("Asset ID:", asset["id"])
61
+ print("Original URL:", asset["url"])
62
+
63
+ thumb_url = client.transform_url(
64
+ asset["url"],
65
+ width=400,
66
+ height=400,
67
+ quality=80,
68
+ fit="cover",
69
+ format="webp",
70
+ )
71
+ print("Thumbnail URL:", thumb_url)
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Framework Integration Examples
77
+
78
+ ### FastAPI (Async with `AsyncBigBucket`)
79
+
80
+ ```python
81
+ import os
82
+ from fastapi import FastAPI, File, HTTPException, UploadFile
83
+ from bigbucket import AsyncBigBucket, BigBucketError
84
+
85
+ app = FastAPI()
86
+
87
+
88
+ @app.post("/upload")
89
+ async def upload_image(file: UploadFile = File(...)):
90
+ async with AsyncBigBucket(api_key=os.environ["BIGBUCKET_API_KEY"]) as client:
91
+ try:
92
+ raw_bytes = await file.read()
93
+ asset = await client.upload(
94
+ raw_bytes,
95
+ filename=file.filename or "upload.png",
96
+ content_type=file.content_type or "image/png",
97
+ )
98
+ return {
99
+ "id": asset["id"],
100
+ "url": asset["url"],
101
+ "thumbnail": client.transform_url(
102
+ asset["url"], width=400, height=400, fit="cover", format="webp"
103
+ ),
104
+ }
105
+ except BigBucketError as exc:
106
+ raise HTTPException(status_code=exc.status_code or 500, detail=exc.message)
107
+ ```
108
+
109
+ ### Flask
110
+
111
+ ```python
112
+ import os
113
+ from flask import Flask, jsonify, request
114
+ from bigbucket import BigBucket, BigBucketError
115
+
116
+ app = Flask(__name__)
117
+ client = BigBucket(api_key=os.environ["BIGBUCKET_API_KEY"])
118
+
119
+
120
+ @app.post("/upload")
121
+ def upload_image():
122
+ uploaded = request.files.get("file")
123
+ if not uploaded:
124
+ return jsonify({"error": "Missing file"}), 400
125
+ try:
126
+ asset = client.upload(
127
+ uploaded.stream,
128
+ filename=uploaded.filename,
129
+ content_type=uploaded.mimetype,
130
+ )
131
+ return jsonify({"id": asset["id"], "url": asset["url"]}), 201
132
+ except BigBucketError as exc:
133
+ return jsonify({"error": exc.message}), exc.status_code or 500
134
+ ```
135
+
136
+ ### Django
137
+
138
+ ```python
139
+ import os
140
+ from django.http import JsonResponse
141
+ from django.views.decorators.http import require_POST
142
+ from bigbucket import BigBucket, BigBucketError
143
+
144
+ client = BigBucket(api_key=os.environ["BIGBUCKET_API_KEY"])
145
+
146
+
147
+ @require_POST
148
+ def upload_image(request):
149
+ uploaded = request.FILES.get("file")
150
+ if not uploaded:
151
+ return JsonResponse({"error": "Missing file"}, status=400)
152
+ try:
153
+ asset = client.upload(
154
+ uploaded.read(),
155
+ filename=uploaded.name,
156
+ content_type=uploaded.content_type or "image/png",
157
+ )
158
+ return JsonResponse({"id": asset["id"], "url": asset["url"]}, status=201)
159
+ except BigBucketError as exc:
160
+ return JsonResponse({"error": exc.message}, status=exc.status_code or 500)
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Images & Usage
166
+
167
+ ```python
168
+ # Paginate & filter
169
+ page = client.images.list(page=1, page_size=20, status="ready", format="webp")
170
+
171
+ # Get metadata
172
+ asset = client.images.get("asset-uuid-123")
173
+
174
+ # Delete permanently
175
+ client.images.delete("asset-uuid-123")
176
+
177
+ # Project storage quota metrics
178
+ usage = client.usage.get()
179
+ ```
@@ -0,0 +1,154 @@
1
+ # bigbucket-sdk
2
+
3
+ Official Python SDK for [BigBucket](https://github.com/bigbucket/bigbucket) — developer-first media storage, on-the-fly Sharp image transformations, and Cloudflare R2 CDN delivery for **FastAPI**, **Flask**, and **Django**.
4
+
5
+ ---
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install bigbucket-sdk
11
+ ```
12
+
13
+ ---
14
+
15
+ ## Quickstart
16
+
17
+ Set your API key in environment variables:
18
+
19
+ ```bash
20
+ BIGBUCKET_API_KEY=bb_sec_your_secret_api_key_here
21
+ # BIGBUCKET_API_URL=http://localhost:8000/api/v1
22
+ ```
23
+
24
+ Upload an image and generate a resized WebP CDN URL:
25
+
26
+ ```python
27
+ import os
28
+ from bigbucket import BigBucket
29
+
30
+ client = BigBucket(api_key=os.environ["BIGBUCKET_API_KEY"])
31
+
32
+ with open("./shoe.jpg", "rb") as f:
33
+ asset = client.upload(f, filename="shoe.jpg", content_type="image/jpeg")
34
+
35
+ print("Asset ID:", asset["id"])
36
+ print("Original URL:", asset["url"])
37
+
38
+ thumb_url = client.transform_url(
39
+ asset["url"],
40
+ width=400,
41
+ height=400,
42
+ quality=80,
43
+ fit="cover",
44
+ format="webp",
45
+ )
46
+ print("Thumbnail URL:", thumb_url)
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Framework Integration Examples
52
+
53
+ ### FastAPI (Async with `AsyncBigBucket`)
54
+
55
+ ```python
56
+ import os
57
+ from fastapi import FastAPI, File, HTTPException, UploadFile
58
+ from bigbucket import AsyncBigBucket, BigBucketError
59
+
60
+ app = FastAPI()
61
+
62
+
63
+ @app.post("/upload")
64
+ async def upload_image(file: UploadFile = File(...)):
65
+ async with AsyncBigBucket(api_key=os.environ["BIGBUCKET_API_KEY"]) as client:
66
+ try:
67
+ raw_bytes = await file.read()
68
+ asset = await client.upload(
69
+ raw_bytes,
70
+ filename=file.filename or "upload.png",
71
+ content_type=file.content_type or "image/png",
72
+ )
73
+ return {
74
+ "id": asset["id"],
75
+ "url": asset["url"],
76
+ "thumbnail": client.transform_url(
77
+ asset["url"], width=400, height=400, fit="cover", format="webp"
78
+ ),
79
+ }
80
+ except BigBucketError as exc:
81
+ raise HTTPException(status_code=exc.status_code or 500, detail=exc.message)
82
+ ```
83
+
84
+ ### Flask
85
+
86
+ ```python
87
+ import os
88
+ from flask import Flask, jsonify, request
89
+ from bigbucket import BigBucket, BigBucketError
90
+
91
+ app = Flask(__name__)
92
+ client = BigBucket(api_key=os.environ["BIGBUCKET_API_KEY"])
93
+
94
+
95
+ @app.post("/upload")
96
+ def upload_image():
97
+ uploaded = request.files.get("file")
98
+ if not uploaded:
99
+ return jsonify({"error": "Missing file"}), 400
100
+ try:
101
+ asset = client.upload(
102
+ uploaded.stream,
103
+ filename=uploaded.filename,
104
+ content_type=uploaded.mimetype,
105
+ )
106
+ return jsonify({"id": asset["id"], "url": asset["url"]}), 201
107
+ except BigBucketError as exc:
108
+ return jsonify({"error": exc.message}), exc.status_code or 500
109
+ ```
110
+
111
+ ### Django
112
+
113
+ ```python
114
+ import os
115
+ from django.http import JsonResponse
116
+ from django.views.decorators.http import require_POST
117
+ from bigbucket import BigBucket, BigBucketError
118
+
119
+ client = BigBucket(api_key=os.environ["BIGBUCKET_API_KEY"])
120
+
121
+
122
+ @require_POST
123
+ def upload_image(request):
124
+ uploaded = request.FILES.get("file")
125
+ if not uploaded:
126
+ return JsonResponse({"error": "Missing file"}, status=400)
127
+ try:
128
+ asset = client.upload(
129
+ uploaded.read(),
130
+ filename=uploaded.name,
131
+ content_type=uploaded.content_type or "image/png",
132
+ )
133
+ return JsonResponse({"id": asset["id"], "url": asset["url"]}, status=201)
134
+ except BigBucketError as exc:
135
+ return JsonResponse({"error": exc.message}, status=exc.status_code or 500)
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Images & Usage
141
+
142
+ ```python
143
+ # Paginate & filter
144
+ page = client.images.list(page=1, page_size=20, status="ready", format="webp")
145
+
146
+ # Get metadata
147
+ asset = client.images.get("asset-uuid-123")
148
+
149
+ # Delete permanently
150
+ client.images.delete("asset-uuid-123")
151
+
152
+ # Project storage quota metrics
153
+ usage = client.usage.get()
154
+ ```
@@ -0,0 +1,60 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "bigbucket-sdk"
7
+ version = "0.1.0"
8
+ description = "Official Python SDK for BigBucket - media storage, Sharp image optimization, and global CDN delivery for Flask, FastAPI, and Django."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "BigBucket Team" }
14
+ ]
15
+ keywords = [
16
+ "bigbucket",
17
+ "image-storage",
18
+ "image-upload",
19
+ "cdn",
20
+ "r2",
21
+ "fastapi",
22
+ "flask",
23
+ "django",
24
+ "sdk"
25
+ ]
26
+ classifiers = [
27
+ "Development Status :: 4 - Beta",
28
+ "Intended Audience :: Developers",
29
+ "License :: OSI Approved :: MIT License",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3.9",
32
+ "Programming Language :: Python :: 3.10",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Programming Language :: Python :: 3.13",
36
+ "Topic :: Internet :: WWW/HTTP",
37
+ "Topic :: Multimedia :: Graphics",
38
+ "Typing :: Typed"
39
+ ]
40
+ dependencies = [
41
+ "httpx>=0.25.0"
42
+ ]
43
+
44
+ [project.optional-dependencies]
45
+ dev = [
46
+ "pytest>=8.0.0"
47
+ ]
48
+
49
+ [tool.setuptools]
50
+ package-dir = { "" = "src" }
51
+
52
+ [tool.setuptools.packages.find]
53
+ where = ["src"]
54
+
55
+ [tool.setuptools.package-data]
56
+ bigbucket = ["py.typed"]
57
+
58
+ [tool.pytest.ini_options]
59
+ testpaths = ["tests"]
60
+ pythonpath = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,77 @@
1
+ """Official BigBucket Python SDK for Flask, FastAPI, and Django."""
2
+
3
+ from .client import AsyncBigBucket, BigBucket
4
+ from .errors import (
5
+ AuthenticationError,
6
+ BigBucketError,
7
+ NotFoundError,
8
+ PayloadTooLargeError,
9
+ RateLimitError,
10
+ StorageUploadError,
11
+ TimeoutError,
12
+ UnsupportedFormatError,
13
+ )
14
+ from .resources import (
15
+ AsyncImagesResource,
16
+ AsyncUploadsResource,
17
+ AsyncUsageResource,
18
+ ImagesResource,
19
+ UploadsResource,
20
+ UsageResource,
21
+ )
22
+ from .transform import build_transform_url
23
+ from .types import (
24
+ DeleteResult,
25
+ FileInput,
26
+ ImageAsset,
27
+ ImageFormat,
28
+ ImageStatus,
29
+ ImageVariant,
30
+ PaginatedImages,
31
+ Pagination,
32
+ PresignedDetails,
33
+ TransformFit,
34
+ TransformFormat,
35
+ UploadMode,
36
+ UploadSession,
37
+ UploadStatus,
38
+ UsageSummary,
39
+ )
40
+
41
+ __version__ = "0.1.0"
42
+
43
+ __all__ = [
44
+ "BigBucket",
45
+ "AsyncBigBucket",
46
+ "build_transform_url",
47
+ "ImagesResource",
48
+ "AsyncImagesResource",
49
+ "UploadsResource",
50
+ "AsyncUploadsResource",
51
+ "UsageResource",
52
+ "AsyncUsageResource",
53
+ "BigBucketError",
54
+ "AuthenticationError",
55
+ "NotFoundError",
56
+ "PayloadTooLargeError",
57
+ "UnsupportedFormatError",
58
+ "RateLimitError",
59
+ "StorageUploadError",
60
+ "TimeoutError",
61
+ "DeleteResult",
62
+ "FileInput",
63
+ "ImageAsset",
64
+ "ImageFormat",
65
+ "ImageStatus",
66
+ "ImageVariant",
67
+ "PaginatedImages",
68
+ "Pagination",
69
+ "PresignedDetails",
70
+ "TransformFit",
71
+ "TransformFormat",
72
+ "UploadMode",
73
+ "UploadSession",
74
+ "UploadStatus",
75
+ "UsageSummary",
76
+ "__version__",
77
+ ]