# Method: projects.locations.corpora.assets.upload

- [HTTP request](https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#body.aspect)
- [IAM Permissions](https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#body.aspect_1)
- [AssetSource](https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#AssetSource)
  - [JSON representation](https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#AssetSource.SCHEMA_REPRESENTATION)
- [AssetContentData](https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#AssetContentData)
  - [JSON representation](https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#AssetContentData.SCHEMA_REPRESENTATION)

Upload asset by specifing the asset Cloud Storage uri. For video warehouse, it requires users who call this API have read access to the cloud storage file. Once it is uploaded, it can be retrieved by assets.generateRetrievalUrl API which by default, only can retrieve cloud storage files from the same project of the warehouse. To allow retrieval cloud storage files that are in a separate project, it requires to find the vision ai service account (Go to IAM, check checkbox to show "Include Google-provided role grants", search for "Cloud Vision AI Service Agent") and grant the read access of the cloud storage files to that service account.

### HTTP request

`POST https://visionai.googleapis.com/v1alpha1/{name=projects/*/locations/*/corpora/*/assets/*}:upload`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `name` | `string` Required. The resource name of the asset to upload. Format: `projects/{project_number}/locations/{locationId}/corpora/{corpus_id}/assets/{assetId}` |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "assetSource": { object (`https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#AssetSource`) } } ``` |

| Fields ||
|---|---|
| `assetSource` | ``object (`https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#AssetSource`)`` The source of the asset. |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/vision-ai/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation`.

### Authorization scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://cloud.google.com/docs/authentication/).

### IAM Permissions

Requires the following [IAM](https://cloud.google.com/iam/docs) permission on the `name` resource:

- `visionai.assets.upload`

For more information, see the [IAM documentation](https://cloud.google.com/iam/docs).

## AssetSource

The source of the asset.

| JSON representation |
|---|
| ``` { // Union field `source_form` can be only one of the following: "assetGcsSource": { object (`https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets#AssetGcsSource`) }, "assetContentData": { object (`https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#AssetContentData`) } // End of list of possible types for union field `source_form`. } ``` |

| Fields ||
|---|---|
| Union field `source_form`. `source_form` can be only one of the following: ||
| `assetGcsSource` | ``object (`https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets#AssetGcsSource`)`` The source of the asset is from Cloud Storage. |
| `assetContentData` | ``object (`https://docs.cloud.google.com/vision-ai/docs/reference/rest/v1alpha1/projects.locations.corpora.assets/upload#AssetContentData`)`` The source of the asset is from content bytes. |

## AssetContentData

The content of the asset.

| JSON representation |
|---|
| ``` { "assetContentData": string } ``` |

| Fields ||
|---|---|
| `assetContentData` | `string (https://developers.google.com/discovery/v1/type-format format)` A base64-encoded string. |