implemented mutiple download feature.
This commit is contained in:
@ -80,3 +80,17 @@ class FileApi(BaseApi):
|
||||
response = self._get(url)
|
||||
self._raise_response_error(response)
|
||||
return response.json()
|
||||
|
||||
def download(self, file: File, path: str) -> bool:
|
||||
print(self.__class__.__name__ + "::" + sys._getframe().f_code.co_name)
|
||||
url = self.connection.build_url("v2/", file.download_url)
|
||||
r = self.connection.session.get(url, stream=True)
|
||||
try:
|
||||
with open(path, "wb") as f:
|
||||
for chunk in r.iter_content(chunk_size=4096):
|
||||
if chunk:
|
||||
f.write(chunk)
|
||||
f.flush()
|
||||
except PermissionError:
|
||||
print(f"Cannot create file `{path}`: Permission denied.")
|
||||
return True
|
||||
|
Reference in New Issue
Block a user