
Answer-first summary for fast verification
Answer: Deploy your Python code as a Cloud Function and set the Cloud Storage bucket as the trigger resource.
Option B is the correct choice because Cloud Functions can directly respond to changes in a Cloud Storage bucket, such as new object uploads, by triggering the function automatically. This method is efficient and specifically designed for such use cases. Option A suggests using Google Kubernetes Engine, which is overkill for this simple task. Option C involves App Engine and Cloud Scheduler, which doesn't directly address the need for triggering on uploads. Option D proposes Dataflow, which is more suited for large-scale data processing rather than immediate, small-scale tasks like resizing images upon upload. For more details, refer to [Cloud Functions documentation](https://cloud.google.com/functions/docs/calling/storage#event_types).
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
You've developed a Python function to resize images for your web application portal. This function should execute automatically whenever a new object is uploaded to a Cloud Storage bucket. What's the best approach to achieve this?
A
Set up Google Kubernetes Engine to run your application and use Pub/Sub with a CRON job for triggering.
B
Deploy your Python code as a Cloud Function and set the Cloud Storage bucket as the trigger resource.
C
Utilize App Engine for running the Python code and configure Cloud Scheduler along with Pub/Sub to trigger it.
D
Implement a batch job using Dataflow, configuring the bucket as the data source.