# Connecting to external data

## Overview

If you are storing images in the external data source such as amazon aws or Google Drive, you can connect to these images from AnnoStation.&#x20;

These images will remain in the external data source and will not be uploaded to AnnoStation.&#x20;

To connect to the external data source, you need to follow these steps:

* Prepare a CSV file
* Import the CSV file to AnnoStation
* Configure the CORS settings

## Prepare CSV file

Include the following fields in your CSV file.

| Field      | Description                                                                             |
| ---------- | --------------------------------------------------------------------------------------- |
| `filename` | A user generated image name. This string is used as a name of the image in AnnoStation. |
| `imageURL` | HTTPS path to the external **image** URL                                                |

Example:

```
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
```

## Import CSV file

To import the CSV file to AnnoStation:

1. Select **New** and choose `Import file`.
2. Click the `Use External Data` tab.&#x20;
3. Select **Choose File** and then select the CSV file you prepared.&#x20;
4. Click **Import**.

{% hint style="info" %}
When the CSV file contains images with the same name as the existing images in AnnoStation, you can either **skip** such images or **overwrite** the existing ones.
{% endhint %}

{% hint style="info" %}
An icon next to an image indicates if the image is <img src="/files/-MFibxkpIqUffPg7LwKN" alt="" data-size="line"> uploaded to AnnoStation or <img src="/files/-MFiccrlEH139gfs7itR" alt="" data-size="line"> stored in the external data source.
{% endhint %}

### Check the URL of the image file

You can check the URL manually for images that are stored in the external data source, and then change the value if needed.

1. Go to an image you want to check the URL path, select the `...` button on the right and then choose `File settings`.
2. This opens the External dataset editing dialog. You can change the file name and URL, and click on **Save**.

## Setup **Cross-origin resource sharing** (**CORS**) option

Cross-origin resource sharing (CORS) is a mechanism that allows resources, in this case images, to be requested from AnnoStation which belongs to another domain outside the domain from which the first resource was served such as amazon aws or Google Drive.

In order for AnnoStation to successfully display an image, you need to configure the external data source to allow cross-origin requests.

If cross-origin requests are not allowed, AnnoStation will not be able to display images. In that case, you can force all the images to be rendered from the AnnoStation server. To turn it on:

1. Go to the `Setting` page of the Project.
2. Open `Advanced settings`, and then select `Force all the images render from server to prevent CORS issue`.
3. Click on **Update Project**.

{% hint style="warning" %}
If the image cannot be displayed due to the CORS issue, AnnoStation will display the error message. If you see the error, try enabling the CORS option.
{% 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/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.
