# 56. Ladda upp foton

Uppladdning av ett foto via S3 innehåller 2 steg:

1. **Begär den försignerade länken för direkt uppladdning.**&#x20;

Som indata:&#x20;

* fileExtention - jpeg ELLER jpg ELLER png,&#x20;
* farmUuid - gårdens uuid,
* fieldUuid - fältets uuid,
* noteUuid - notens uuid för direktlänken till det uppladdade fotot,
* commentUuid - kommentarens uuid för direktlänken till det uppladdade fotot (valfritt).&#x20;

Som utdata:

* uuid - den förväntade uuid efter uppladdning och bearbetning,
* farmUuid - samma som indata,
* fieldUuid - samma som indata,
* noteUuid - samma som indata,
* commentUuid - samma som indata (om den fanns),
* s3Url - URL:en som används för att ladda upp fotot,
* s3Fields - attribut som ska skickas i formuläret för foto-uppladdning.

Detaljer om hur man använder s3Url och s3Fields beskrivs i det andra steget.&#x20;

Attributen är giltiga endast i 60 minuter för att ladda upp fotot.

{% 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
    s3Fields
  }
}
```

{% endcode %}

2. **Skicka ett lokalt foto till s3Url med fördefinierade formulärattribut från s3Fields.**

{% 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 %}

Aviseringar om bearbetningen levereras via prenumerationsmekanismen som beskrivs i GraphQL -> Samples -> [1. Prenumeration: Hämta händelser](/geopard-tutorials/swe/api-dokumentation/oversikt-over-geopard-api-anrop/1.-prenumeration-hamta-handelser.md).

{% hint style="info" %}
Använd ‘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/swe/api-dokumentation/oversikt-over-geopard-api-anrop/56.-ladda-upp-foton.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.
