# 56. Upload photos

Uploading a photo via S3 contains 2 steps:

1. **Request the pre-signed link for further direct upload.**&#x20;

As input:&#x20;

* fileExtention - jpeg OR jpg OR png,&#x20;
* farmUuid - uuid of the farm,
* fieldUuid - uuid of the field,
* noteUuid - uuid of the note for the direct link of the uploaded photo,
* commentUuid - uuid of the comment for the direct link of the uploaded photo (optional).&#x20;

As output:

* uuid - the expected uuid after the upload and processing,
* farmUuid - the same as input,
* fieldUuid - the same as input,
* noteUuid - the same as input,
* commentUuid - the same as input (if existed),
* s3Url - the URL used to upload the photo,
* s3Fields - attributes to pass in the upload photo form.

The details of how to use s3Url and s3Fields are described in the second step.&#x20;

The attributes are valid for only 60 mins to upload the photo.

{% 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. **Send a local photo to s3Url with predefined form attributes from 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 %}

Notifications about the processing will be delivered via the subscription mechanism described in GraphQL -> Samples -> [1. Subscription: Get events](https://docs.geopard.tech/geopard-tutorials/api-docs/requests-overview/1.-subscription-get-events).

{% hint style="info" %}
Use ‘Accept-Encoding’:’gzip, deflate, br’.
{% endhint %}
