# 外部データを使用する

## 概要

amazon awsやGoogle Driveなどの外部データソースに画像を保存している場合、AnnoStationからこれらの画像に接続することができます。

これらの画像は外部データソースに保存されたままで、AnnoStationにはアップロードされません。

外部データソースに接続するには、以下の手順に従ってください。

* CSVファイルを準備します
* CSVファイルを AnnoStation にインポートします
* CORS の設定を行います

## CSVファイルを準備します

以下のフィールドをCSVファイルに含めてください。

| Field      | Description                                     |
| ---------- | ----------------------------------------------- |
| `filename` | ユーザーが生成した画像名。この文字列は、AnnoStationで画像の名前として使用されます。 |
| `imageURL` | 外部に保存された画像URLのパス                                |

例:

```
filename,url
42515384_external.jpg,http://127.0.0.1:8080/static/42515384_copy.jpg
73037153_external.jpg,http://127.0.0.1:8080/static/73037153.jpg
73037866_external.jpg,http://127.0.0.1:8080/static/73037866.jpg
10280687_external.jpg,http://127.0.0.1:8080/static/10280687.jpg
m_768_42515384_external.jpg,http://127.0.0.1:8080/static/m_768_42515384.jpg
```

## CSVファイルをインポートする

CSV ファイルを AnnoStation にインポートするには、以下の手順に従います。

1. **New**を選択し、Import fileを選択する。
2. `Use External Data`タブをクリックする。
3. **Choose Files**を選択し、用意したCSVファイルを選択します。
4. **Import**をクリックします。

{% hint style="info" %}
CSVファイル内の画像名がAnnoStation内にすでに存在する場合、そのような画像を**スキップ**するか、既存の画像を**上書き**するかを選択できます。
{% endhint %}

{% hint style="info" %}
画像の横にあるアイコンは、画像が AnnoStation にアップロードされている<img src="/files/-MFibxkpIqUffPg7LwKN" alt="" data-size="line">か、外部データソースに保存されている<img src="/files/-MFiccrlEH139gfs7itR" alt="" data-size="line">かを示します。
{% endhint %}

### 画像ファイルのURLを確認する

外部データソースに保存されている画像のURLを手動で確認し、必要に応じて値を変更することができます。

1. URLパスを確認したい画像に移動し、右側の `...` ボタンを選択して、`File settings`を選択します。
2. 外部データセットの編集ダイアログが開きます。ファイル名とURLを変更し、**保存**をクリックします。

## **Cross-origin resource sharing** (**CORS**) オプションの設定

Cross-origin resource sharing (CORS) とは、amazon aws や Google Drive のようなリソース（この場合は画像）を提供するドメインに対して、そのドメイン以外の別のドメインに属する AnnoStationが リソースをリクエストできるようにするメカニズムです。

AnnoStationが画像を正常に表示するためには、Cross-origin requestを許可するように外部データソースを設定する必要があります。

Cross-origin requestが許可されていない場合、AnnoStationは画像を表示することができません。その場合は、すべての画像をAnnoStationサーバーから強制的にレンダリングすることができます。これを有効にするには、以下の手順に従ってください。

1. プロジェクトの `Setting` タブを開きます。
2. `Advanced settings`を開き、`Force all the images render from server to prevent CORS issue`を選択します。
3. **Update Project**をクリックします。

{% hint style="warning" %}
CORSの問題で画像が表示できない場合、AnnoStationはエラーメッセージを表示します。エラーが表示された場合は、CORSオプションを有効にしてみてください。
{% endhint %}


---

# 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://docs.annostation.orni.co.jp/jpn/mastering-annostation/projectsetup/data-set/connecting-to-external-data.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.
