Skip to content

Commit b156225

Browse files
authored
Merge branch 'v0.1.2' into feature/file-tags
2 parents c2cc518 + a7ee467 commit b156225

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/lighthouseweb3/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,21 @@ def downloadBlob(dist: io.BufferedWriter, cid: str, chunk_size=1024*1024*10) ->
5858
except Exception as e:
5959
raise e
6060

61+
@staticmethod
62+
def downloadBlob(dist: io.BufferedWriter, cid: str, chunk_size=1024*1024*10) -> t.Upload:
63+
"""
64+
Download Blob a file or directory to the Lighthouse.
65+
66+
:param source: str, path to file or directory
67+
:return: t.Upload, the upload result
68+
"""
69+
if not (hasattr(dist, 'read') and hasattr(dist, 'close')):
70+
raise TypeError("source must have 'read' and 'close' methods")
71+
try:
72+
return _download.download_file_into_writable(cid, dist, chunk_size)
73+
except Exception as e:
74+
raise e
75+
6176
@staticmethod
6277
def getDealStatus(cid: str) -> List[t.DealData]:
6378
"""
@@ -110,3 +125,4 @@ def getTagged(self, tag: str) -> t.Upload:
110125
return _download.getTaggedCid(tag, self.token)
111126
except Exception as e:
112127
raise e
128+

tests/test_download.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ def test_download_blob_file(self):
4343
123939, "File Size dont match")
4444

4545

46+
4647
if __name__ == "__main__":
4748
unittest.main()

0 commit comments

Comments
 (0)