# 56. 写真をアップロード

S3を介して写真をアップロードするには2つのステップがあります：

1. **直接アップロードのための事前署名リンクをリクエストします。**&#x20;

入力として：&#x20;

* fileExtention - jpeg または jpg または png、&#x20;
* farmUuid - 農場のUUID、
* fieldUuid - 区画（圃場）のUUID、
* noteUuid - アップロードされた写真の直接リンクを関連付けるノートのUUID、
* commentUuid - アップロードされた写真の直接リンクを関連付けるコメントのUUID（オプション）。&#x20;

出力として：

* uuid - アップロードおよび処理後に期待されるUUID、
* farmUuid - 入力と同じ値、
* fieldUuid - 入力と同じ値、
* noteUuid - 入力と同じ値、
* commentUuid - 入力と同じ値（存在する場合）、
* s3Url - 写真をアップロードするために使用するURL、
* s3Fields - 写真アップロードフォームに渡す属性。

s3Urlとs3Fieldsの使い方の詳細は第2ステップで説明されています。&#x20;

これらの属性は写真をアップロードするためにのみ60分間有効です。

{% code overflow="wrap" lineNumbers="true" %}

```graphql
mutation generatePresignedPostPhotoData {
  generatePresignedPostPhotoData(input:{
    farmUuid: "89196056-61e5-4bce-b676-d488d611a829" 
    fieldUuid: "586a2ef2-03e4-4715-846c-07a2f0cb3016"
    noteUuid: "4a94da1c-f655-4f17-961a-4b0323e5129c"
    fileExtention: jpeg
    
  } ) {
    uuid
    noteUuid
    fieldUuid
    farmUuid
    s3Url（S3 の URL）
    s3Fields（S3 フォームフィールド）
  }
}
```

{% endcode %}

2. **ローカルの写真をs3Fieldsで指定されたフォーム属性とともにs3Urlへ送信します。**

{% code overflow="wrap" lineNumbers="true" %}

```bash
curl --location --request POST '<s3Url>' \
--form 'key="<value_in_s3Fields>"' \
--form 'AWSAccessKeyId="<value_in_s3Fields>"' \
--form 'x-amz-security-token="<value_in_s3Fields>"' \
--form 'policy="<value_in_s3Fields>"' \
--form 'signature="<value_in_s3Fields>"' \
--form 'file=@"<local_file_path>"'
```

{% endcode %}

処理に関する通知は、GraphQL -> Samples -> に記載されたサブスクリプション機構を介して配信されます。 [1. サブスクリプション：イベントを取得する](/geopard-tutorials/jpn/apidokyumento/geopard-apirikuesuto/1-sabusukuripushon-ibentowo.md).

{% hint style="info" %}
‘Accept-Encoding’:’gzip, deflate, br’ を使用してください。
{% 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.geopard.tech/geopard-tutorials/jpn/apidokyumento/geopard-apirikuesuto/56-woappurdo.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.
