I can run the following to download the file "some/path/known_name.json"
def download_file():
try:
file_system_client = FileSystemClient.from_connection_string(...)
full_file_location = "some/path/known_name.json"
target_file_client = file_system_client.get_file_client(full_file_location)
download=target_file_client.download_file()
downloaded_bytes = download.readall()
local_file = open('my_file.json','wb')
local_file.write(downloaded_bytes)
local_file.close()
except Exception as e:
print(e)
My question is: how do I download from some other path when the name of the file is unknown but the file type is known e.g. "different/path/xxx.json"
You can list the blobs in the container and then filter the json files by the
blob.name
.Here is my blobs in my test container:
Here is my python code:
When I run the code, it will download the
data.json
anddata2.json
.