22
22
from tempfile import mkstemp
23
23
from zipfile import ZIP_DEFLATED , ZipFile
24
24
25
- from azure .storage .blob import BlobService
25
+ from azure .storage .blob import BlockBlobService
26
+ from azure .storage .blob .models import ContentSettings
26
27
from azure .storage .queue import QueueService
27
28
from azure .storage .table import TableService
28
29
@@ -48,7 +49,7 @@ def __init__(self,
48
49
max_connections = 1 ,
49
50
max_retries = 5 ,
50
51
retry_wait = 1.0 ):
51
- self .service = BlobService (account_name , account_key , protocol )
52
+ self .service = BlockBlobService (account_name , account_key , protocol )
52
53
self .container_created = False
53
54
hostname = gethostname ()
54
55
self .meta = {'hostname' : hostname .replace ('_' , '-' ),
@@ -79,13 +80,12 @@ def put_file_into_storage(self, dirName, fileName):
79
80
file_path = tmpfile_path
80
81
else :
81
82
suffix , content_type = '' , 'text/plain'
82
- self .service .put_block_blob_from_path (self .container ,
83
- fileName + suffix ,
84
- file_path ,
85
- x_ms_blob_content_type = content_type ,
86
- max_connections = self .max_connections ,
87
- max_retries = self .max_retries ,
88
- retry_wait = self .retry_wait )
83
+ self .service .create_blob_from_path (container_name = self .container ,
84
+ blob_name = fileName + suffix ,
85
+ file_path = fileName ,
86
+ content_settings = ContentSettings (content_type = content_type ),
87
+ max_connections = self .max_connections
88
+ ) # max_retries and retry_wait no longer arguments in azure 0.33
89
89
finally :
90
90
if self .zip_compression and fd :
91
91
os .remove (tmpfile_path )
0 commit comments