Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Storage Search Files

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.

like image 625
JohanLejdung Avatar asked Dec 20 '16 17:12

JohanLejdung


People also ask

How do I find files in Cloud Storage?

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.

How do I access Google storage files?

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.

How does Google Cloud Search work?

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.


2 Answers

In your example, you could achieve this using wildcards with gsutil to list your bucket contents:

gsutil ls gs://your-bucket/car*/receipt

like image 78
Travis Hobrla Avatar answered Sep 21 '22 21:09

Travis Hobrla


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.

like image 41
user10895065 Avatar answered Sep 22 '22 21:09

user10895065