
# Host Assets on Google Cloud Storage

[Google Cloud Storage](https://cloud.google.com/storage) is a managed object storage service offering high availability,
global redundancy, and fine-grained access controls. Store and serve your assets from Google's infrastructure.

By using the Google Cloud Storage destination you can immediately send your assets to your own GCS bucket, making it
quick and easy to host your assets in your own Google Cloud account.

### Setup

Sign up to Google Cloud and create a Cloud Storage bucket if you have not already set one up. Google Cloud credentials
are required and must be added via the Shotstack [dashboard](https://dashboard.shotstack.io).

### Adding credentials

Login to the dashboard and navigate to the [integrations](https://dashboard.shotstack.io/integrations) page, find the
Google Cloud Storage destination and click
[configure](https://dashboard.shotstack.io/integrations/google-cloud-storage).

Enter your credentials as shown. You can add different credentials for each Shotstack environment; sandbox and v1
(production).

### Integration

#### Basic integration

To send files to Google Cloud Storage add the following to the output parameter of a render request JSON payload, JSON
template or the root level of an ingest request:

```json
"destinations": [{
    "provider": "google-cloud-storage",
    "options": {
        "bucket": "my-bucket"
    }
}]
```

This will send the generated or ingested files to the **my-bucket** bucket. The filename will be the render id, source
id or rendition id plus extension, i.e. **edc47d30-a504-4f16-8439-24c863a7a782.mp4** and will be saved to the root level
of the bucket. Thumbnail and poster images will also be transferred.

#### Advanced integration

You can also optionally set a prefix (folder path) and custom file name:

```json
"destinations": [{
    "provider": "google-cloud-storage",
    "options": {
        "bucket": "my-bucket",
        "prefix": "my-renders",
        "filename": "video"
    }
}]
```

This will send the rendered files to the **my-bucket** bucket. If the rendered file is an mp4, the filename will be
**video.mp4** and will be saved with a prefix **my-renders**.

When using a custom filename omit the file extension, i.e. .mp4 or .jpg. This will be added based on the rendered file
type. If a poster or thumbnail are created these will have **-poster.jpg** and **-thumbnail.jpg** appended.

#### Sending assets to multiple buckets

It is also possible to send files to multiple buckets with one request:

```json
"destinations": [{
    "provider": "google-cloud-storage",
    "options": {
        "bucket": "my-bucket"
    }
},{
    "provider": "google-cloud-storage",
    "options": {
        "bucket": "my-other-bucket",
        "prefix": "backups"
    }
}]
```

This will send rendered assets to **my-bucket** and to the **backups** prefix of **my-other-bucket**. Buckets must be
accessible by the configured credentials.

### Opting out from the Shotstack destination

By default all generated files are sent to the Shotstack destination. If you are using Google Cloud Storage you may wish
to [opt out](../self-host.md) from hosting your videos with Shotstack using:

```json
"destinations": [{
    "provider": "google-cloud-storage",
    "options": {
        "bucket": "my-bucket"
    }
},{
    "provider": "shotstack",
    "exclude": true
}]
```

This will send the generated video to Google Cloud Storage but not to Shotstack.
