Google Cloud Professional Cloud Developer — Question 198
You are developing an application that needs to store files belonging to users in Cloud Storage. You want each user to have their own subdirectory in Cloud Storage. When a new user is created, the corresponding empty subdirectory should also be created. What should you do?
Answer options
- A. Create an object with the name of the subdirectory ending with a trailing slash ('/') that is zero bytes in length.
- B. Create an object with the name of the subdirectory, and then immediately delete the object within that subdirectory.
- C. Create an object with the name of the subdirectory that is zero bytes in length and has WRITER access control list permission.
- D. Create an object with the name of the subdirectory that is zero bytes in length. Set the Content-Type metadata to CLOUDSTORAGE_FOLDER.
Correct answer: A
Explanation
The correct answer is A because creating an object with a name that ends in a trailing slash ('/') effectively creates a folder in Cloud Storage. The other options either do not create the desired folder structure or involve unnecessary steps that do not achieve the requirement of creating an empty subdirectory.