# Cloud storage 串接 Cloud CDN

## Cloud storage

Cloud storage 為類似 S3 的服務，串接 Cloud CDN 後可做到檔案快取。

上傳檔案後設定權限為 public 就會產生可下載的 URL

![](/files/-MMKZ2rXOqgoVptHvWuT)

## Cloud CDN

{% embed url="<https://cloud.google.com/cdn/docs/resources?hl=zh-tw>" %}

需要先建立 後端 bucket 與 load balancing

![](/files/-MMKZw2loubIoSuiavK0)

然後

![](/files/-MMKZzr9M8ZD8x26_KIz)

之後會給你一個 IP

![](/files/-MMK_5SGtMG_9siJLT6A)

原本 cloud storage&#x20;

```
https://storage.googleapis.com/<bucket name>/<object name>
```

改為以下即可

```
<cloud cdn ip>/<object name>
```

> 如果直接設定 http load balancing 然後有打勾 cdn 之後也會出現在 cloud cdn 看到新增東西出來，但可能會連不上去，建議還是在cloud cdn 建立

## 權限設定

cloud storage 可以設定 domain 權限，或是也可以產生 sign URL 來讓特定權限的帳戶存取<https://cloud.google.com/cdn/docs/using-signed-urls>

## 相關文章

{% embed url="<https://cloud.google.com/cdn/docs/setting-up-cdn-with-bucket>" %}

<https://medium.com/techintoo/serving-static-files-using-google-cloud-cdn-storage-bucket-db1287cb5e40>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://easonwang.gitbook.io/web_advance/bu_shu_dao_google_engine__gce/cloud-storage-chuan-jie-cloud-cdn.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
