python-dropbox-api 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl

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,4 +1,4 @@
1
- from collections.abc import AsyncIterator
1
+ from collections.abc import AsyncIterator, Callable
2
2
  import json
3
3
 
4
4
  from aiohttp import ClientResponse
@@ -238,6 +238,7 @@ class DropboxAPIClient:
238
238
  path: str,
239
239
  file_stream: AsyncIterator[bytes],
240
240
  property_groups: list[PropertyGroup] | None = None,
241
+ progress_callback: Callable[[int], None] | None = None,
241
242
  ) -> None:
242
243
  """Upload a file to Dropbox using chunked upload sessions.
243
244
 
@@ -245,13 +246,19 @@ class DropboxAPIClient:
245
246
  path: The Dropbox path where the file should be uploaded.
246
247
  file_stream: An async iterator of bytes to upload.
247
248
  property_groups: Optional list of property groups to attach to the uploaded file.
249
+ progress_callback: Optional callback called with the total number of bytes uploaded after each chunk is sent.
248
250
  """
249
251
  try:
250
252
  CHUNK_SIZE = 16 * 1024 * 1024 # 16MB chunks
251
253
 
252
254
  # Always use chunked upload approach
253
255
  await self._upload_file_chunked(
254
- CONTENT_API_BASE_URL, path, file_stream, CHUNK_SIZE, property_groups
256
+ CONTENT_API_BASE_URL,
257
+ path,
258
+ file_stream,
259
+ CHUNK_SIZE,
260
+ property_groups,
261
+ progress_callback,
255
262
  )
256
263
  except (DropboxAuthException, DropboxFileOrFolderNotFoundException):
257
264
  raise
@@ -265,6 +272,7 @@ class DropboxAPIClient:
265
272
  file_stream: AsyncIterator[bytes],
266
273
  chunk_size: int,
267
274
  property_groups: list[PropertyGroup] | None = None,
275
+ progress_callback: Callable[[int], None] | None = None,
268
276
  ) -> None:
269
277
  """Upload a file using chunked upload sessions, streaming chunks without loading entire file into memory."""
270
278
  session_id = None
@@ -295,6 +303,8 @@ class DropboxAPIClient:
295
303
  )
296
304
 
297
305
  offset += len(chunk_data)
306
+ if progress_callback:
307
+ progress_callback(offset)
298
308
 
299
309
  # Handle remaining data in buffer (final partial chunk)
300
310
  if buffer:
@@ -307,6 +317,8 @@ class DropboxAPIClient:
307
317
  content_api_url, session_id, offset, buffer
308
318
  )
309
319
  offset += len(buffer)
320
+ if progress_callback:
321
+ progress_callback(offset)
310
322
 
311
323
  # Empty file (or a stream that yielded no bytes): no session was ever
312
324
  # started, so open one with no data before finishing.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-dropbox-api
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: This is a lightweight wrapper for the Dropbox API intended for use in Home Assistant.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -10,6 +10,7 @@ Requires-Python: >=3.13
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 3.13
12
12
  Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Programming Language :: Python :: 3.15
13
14
  Requires-Dist: aiohttp (>=3.13.0,<4.0.0)
14
15
  Description-Content-Type: text/markdown
15
16
 
@@ -1,10 +1,10 @@
1
1
  python_dropbox_api/__init__.py,sha256=8NVlyqQZvA0Mgds5Pb80irBac5mGPJFwW4MEeMFPOvU,575
2
2
  python_dropbox_api/auth.py,sha256=qrPop5F2_UGDmEtNOwhuYwgoHyaQ_wCjeP0B7tMNx38,448
3
- python_dropbox_api/client.py,sha256=vbLmhwbq2yznZtoS5ErOw5qUOnv_51rCM3hUKXcje6k,23484
3
+ python_dropbox_api/client.py,sha256=_Y0Fh7KAE-Zv2rEAuKO1ueT-zpllIA2EOzBGXT8tYKU,24004
4
4
  python_dropbox_api/exceptions.py,sha256=HZ8Cf1ET6uqMmMIOXmtRqgLaz59GdYm8fBKLPBnXt-M,706
5
5
  python_dropbox_api/models.py,sha256=yhkfVMKPsMJxMzLA0KhSUPt_uoJkrvVjeskKffTKt-M,1604
6
6
  python_dropbox_api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- python_dropbox_api-0.1.4.dist-info/METADATA,sha256=Kl5T4KAcjUIUMQbSX1hAep_QBS4YBtyogqPGsiYm0-w,647
8
- python_dropbox_api-0.1.4.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
9
- python_dropbox_api-0.1.4.dist-info/licenses/LICENSE,sha256=KEwQxPRqHS1CBUYJkUYSb-dkreLlur_kqtOdilr7SC4,1075
10
- python_dropbox_api-0.1.4.dist-info/RECORD,,
7
+ python_dropbox_api-0.1.5.dist-info/METADATA,sha256=i6YwiiWXBYjGofCKrm-5HxdbS2WNSEgi6oMYZzytK9o,698
8
+ python_dropbox_api-0.1.5.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
9
+ python_dropbox_api-0.1.5.dist-info/licenses/LICENSE,sha256=KEwQxPRqHS1CBUYJkUYSb-dkreLlur_kqtOdilr7SC4,1075
10
+ python_dropbox_api-0.1.5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.4.1
2
+ Generator: poetry-core 2.5.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any