I'm developing an application that will serve a lot of file. Lets say it's a car company. Each car has a folder with documents/files for that car. These files are uploaded into categories, represented as "folders" in GStorage. 2 files for 2 different cars could look like this:
car1/receipt/2016-02-02_payment.pdf
car1/pictures/tires.png
car2/receipt/2016-01-02_payment.pdf
Lets say I want to list all receipts in my application. How would I do this? Since the search capabilities in Google Cloud Storage is very limited my current proposed solution is to have a mirrored database table with all of the files in it, when i want to access the files i generate the URL for the user. It would be very nice is GStorage had a way to search for */ files.
Find files in Google Drive You would expect Google products to come with a good search function, and that's exactly the case with its cloud storage platform. At the top of the Google Drive web interface there is a large search box—results will include file names and documents that contain the words you used.
Your storage is shared across Google Drive, Gmail, and Google Photos. When your account reaches its storage limit, you can't send or receive emails. To see how much space you have left, on a computer, go to google.com/settings/storage.
Use Google Cloud Search to find the information you need at work—from anywhere, using your laptop, mobile phone, or tablet. It searches across your organization's content in Google Workspace services or third-party data sources.
In your example, you could achieve this using wildcards with gsutil
to list your bucket contents:
gsutil ls gs://your-bucket/car*/receipt
gsutil supports * and ? wildcards only for files. To include folders in the wildcard target you need to double the * or ? sign. For instance, gsutil ls gs:///**.txt will list all the text files in all subdirectories. The wildcard page offers more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With