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
f7db5595
Commit
f7db5595
authored
Mar 31, 2021
by
Arnaud Jaen
Browse files
Add method to download blob
parent
840143de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
azure_blob_client/__init__.py
azure_blob_client/__init__.py
+8
-3
No files found.
azure_blob_client/__init__.py
View file @
f7db5595
...
...
@@ -6,7 +6,7 @@
from
os
import
remove
from
typing
import
ContextManager
,
Iterator
,
List
import
requests
from
datetime
import
datetime
,
timedelta
import
logging
...
...
@@ -159,9 +159,14 @@ class AzureBlobClient:
: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
())
"""blob_client = self.blob_service_client().get_blob_client(container=container_name, blob=blob_name)
download_stream = blob_client.download_blob()
my_blob.write(download_stream.readall())"""
url
=
self
.
get_blob_sas_url
(
container_name
,
blob_name
)
myfile
=
requests
.
get
(
url
)
my_blob
.
write
(
myfile
.
content
)
def
get_blob_sas_url
(
self
,
container_name
,
blob_name
,
time_to_expiry
=
1
):
...
...
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