0

I'm willing to implement a lazy loading approach to load images stored in an "images" folder inside an azure storage account.

I have a container in my flutter app where whenever the user scrolls down the bottom new 10 images will be loaded from the storage based on the most recent(timestamp).

I looked into this sample retrieved from: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-storage-blob/12.0.0b5/index.html#id20

from azure.storage.blob.aio import ContainerClient

container = ContainerClient.from_connection_string(conn_str="my_connection_string", container_name="my_container")

blob_list = []
async for blob in container.list_blobs():
    blob_list.append(blob)
print(blob_list)

But it's not what I need.I am looking for a way to make a get request that will retrieve me new set of images whenever the function is invoked..

Thankful for suggestions!

DCodes
  • 789
  • 1
  • 11
  • 27

2 Answers2

1

I was able to implement a lazy loading approach by using the marker continuation object

Example:

mark=req.params.get('NextMarker')
entit = table_service.query_entities('UserRequests','PartitionKey eq \'' + emailAddress + '\'',num_results=21,select= '..', marker=mark)
Dict = {"NextMarker": entit.next_marker}
return json.dumps(Dict)

This way I am able to send the marker in the http get request every time to get the second batch.

I hope this helps someone one day!

DCodes
  • 789
  • 1
  • 11
  • 27
0

If you want to list blobs by blob creation time, unfortunately, it is not supported by Azure list blobs API(SDKs are based on APIs). Blob creation time belongs to blob properties, and as the official doc indicates, blob properties can't be set as a request param.

So if you want to fetch all new images for each request, maybe you should get a blob list first and sort them yourself and cut out the items that you need. There will be some extra codes that you need to write. But if you use Azure PowerShell to do that, you can implement the whole process easier. You can refer to this similar requirement.

Stanley Gong
  • 11,522
  • 1
  • 8
  • 16