0

I'm using the python SDK. I know of bucket.list_blobs() and am able to get all the blobs, but I'm wondering - what's the best way to get the most recently uploaded one? I haven't been able to figure this out from the docs.

I can loop through them all and look at the time_created field, but anything more efficient?

Rima
  • 101
  • 1
  • 1
  • 7

1 Answers1

2

Depending on what are going to do with the object I'd suggest looking into the Cloud Storage notifications:

  1. Object Change Notification — can notify the app when an object is updated or added to a bucket.
  2. Cloud Pub/Sub Notifications for Cloud Storage — sends a message to the Pub/Sub service. You can process the message with a handler written in my of supported languages or simply use Cloud Functions to create a lightweight server-less handler.

Just follow the links, there are some examples attached.

xSAVIKx
  • 463
  • 4
  • 12