Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
production
geocannabis--drone-analytics-2
azure-blob-lib
Commits
840143de
Commit
840143de
authored
Mar 30, 2021
by
Arnaud Jaen
Browse files
Add a method to download blob locally
parent
46812582
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
azure_blob_client/__init__.py
azure_blob_client/__init__.py
+15
-0
No files found.
azure_blob_client/__init__.py
View file @
840143de
...
@@ -149,6 +149,21 @@ class AzureBlobClient:
...
@@ -149,6 +149,21 @@ class AzureBlobClient:
"""
"""
self
.
blob_container_client
(
container_name
=
container_name
).
delete_blob
(
blob
=
blob_name
)
self
.
blob_container_client
(
container_name
=
container_name
).
delete_blob
(
blob
=
blob_name
)
def
download_blob
(
self
,
container_name
:
str
,
blob_name
:
str
,
local_filename
:
str
):
"""Function to download a blob within a container
:param container_name: Name of the container
:type container_name: str
:param blob_name: Name of the blob to download
:type blob_name: str
:param local_filename: Name of the local downloaded file
:type local_filename: str
"""
with
open
(
local_filename
,
"wb"
)
as
my_blob
:
download_stream
=
self
.
blob_container_client
(
container_name
=
container_name
).
download_blob
(
blob
=
blob_name
)
my_blob
.
write
(
download_stream
.
readall
())
def
get_blob_sas_url
(
self
,
container_name
,
blob_name
,
time_to_expiry
=
1
):
def
get_blob_sas_url
(
self
,
container_name
,
blob_name
,
time_to_expiry
=
1
):
"""
"""
Get the URL of a blob, with the necessary read access
Get the URL of a blob, with the necessary read access
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment