3
votes

I would like to verify my website in Google Search Console by uploading a file to my website - example.com which is hosted on Google Cloud Compute Engine (Wordpress site deployed with Google Cloud Launcher) . It has to be placed on a website as example.com/123googlesearchconsoleexample.html , but I cannot upload it via Cloud Shell from a Google Cloud Storage bucket. Is there a way to do this?

I tried gcloud compute copy-files command

gcloud compute copy-files gs://example/123googlesearchconsoleexample.html example-prd-vm:~/

, but it seems that it does not work in the browser and this is how I would like to do it (without installing SDK). The error I get is:

(gcloud.compute.copy-files) All sources must be local files when destination is remote.

2
It's not clear to me which terminal you're using, given that you're also talking about wanting to do it from a browser. Are you talking about the Cloud Shell?Jon Skeet
Yes, I am talking about Cloud Shell.Mateusz Kozłowski
Okay, that's progress. I suggest you clarify your question to state that, and also what happened when you tried running gcloud compute copy-files. (The Cloud Shell should already have the gcloud SDK installed, including both the gcloud and gsutil commands.)Jon Skeet
You should also clarify what you mean by "my website" - we don't know how your web site is hosted. Presumably it's in GCP somehow, but there are lots of ways of hosting websites in GCP.)Jon Skeet
Thanks for comments. I edited the question, so it is more clear in topics you mentioned.Mateusz Kozłowski

2 Answers

9
votes

I don't know if there's a way of doing it in a single step, but it looks like it should be easy to do in two steps:

$ gsutil cp gs://example/123googlesearchconsoleexample.html .
$ gcloud compute copy-files 123googlesearchconsoleexample.html example-prd-vm:~/

The first command copies from Google Cloud Storage to the VM running Cloud Shell. The second command then copies from that VM to example-prd-vm... it's now copying a local file, so the error you're currently getting won't be applicable.

1
votes

First list all the buckets you have using the following command

gsutil ls

Use the following command to download a file from your Google Cloud Storage bucket to your local location

gsutil cp gs://bucketname/filename local-location

You can use the -r option to download a folder from GCS

gsutil cp -r gs://bucketname/folder-name local-location

You can also use the -m option to download large number of files which performs a parallel (multi-threaded/multi-processing) copy

gsutil -m cp -r gs://bucketname/folder-name local-location