@@ -173,7 +173,7 @@ func (a *AzureBlobStorage) getObjectNameFromPath(path string) string {
173
173
174
174
// Open opens a file
175
175
func (a * AzureBlobStorage ) Open (path string ) (Object , error ) {
176
- blobClient := a .client . ServiceClient (). NewContainerClient ( a . container ). NewBlobClient ( a . buildAzureBlobPath ( path ) )
176
+ blobClient := a .getBlobClient ( path )
177
177
res , err := blobClient .GetProperties (a .ctx , & blob.GetPropertiesOptions {})
178
178
if err != nil {
179
179
return nil , convertAzureBlobErr (err )
@@ -234,7 +234,7 @@ func (a azureBlobFileInfo) Sys() interface{} {
234
234
235
235
// Stat returns the stat information of the object
236
236
func (a * AzureBlobStorage ) Stat (path string ) (os.FileInfo , error ) {
237
- blobClient := a .client . ServiceClient (). NewContainerClient ( a . container ). NewBlobClient ( a . buildAzureBlobPath ( path ) )
237
+ blobClient := a .getBlobClient ( path )
238
238
res , err := blobClient .GetProperties (a .ctx , & blob.GetPropertiesOptions {})
239
239
if err != nil {
240
240
return nil , convertAzureBlobErr (err )
@@ -249,7 +249,7 @@ func (a *AzureBlobStorage) Stat(path string) (os.FileInfo, error) {
249
249
250
250
// Delete delete a file
251
251
func (a * AzureBlobStorage ) Delete (path string ) error {
252
- blobClient := a .client . ServiceClient (). NewContainerClient ( a . container ). NewBlobClient ( a . buildAzureBlobPath ( path ) )
252
+ blobClient := a .getBlobClient ( path )
253
253
_ , err := blobClient .Delete (a .ctx , & blob.DeleteOptions {})
254
254
return convertAzureBlobErr (err )
255
255
}
@@ -302,6 +302,11 @@ func (a *AzureBlobStorage) IterateObjects(dirName string, fn func(path string, o
302
302
return nil
303
303
}
304
304
305
+ // Delete delete a file
306
+ func (a * AzureBlobStorage ) getBlobClient (path string ) * blob.Client {
307
+ return a .client .ServiceClient ().NewContainerClient (a .container ).NewBlobClient (a .buildAzureBlobPath (path ))
308
+ }
309
+
305
310
func init () {
306
311
RegisterStorageType (setting .AzureBlobStorageType , NewAzureBlobStorage )
307
312
}
0 commit comments