---
# System prepended metadata

title: MVP upload photo via mobile

---

# [Chantier] MVP upload photo via mobile (QR code)


Diagramme de séquence des calls :


````mermaid
sequenceDiagram
		participant czf as Cheerz Front
    participant czb as Cheerz Back
	  participant fo as Fotom
	  czf->>+czb: Fetch upload token
	  czb-->>-czf: Return JWT for access to Fotom
	  Note over czf: POST :/api/identified/:api_version/upload_photos_token
	  czf->>+czb: Fetch generate QR-Code
	  czb-->>-czf: Return QR-Code with string
    czf->>+fo: Call new endpoint on Fotom for upload
		Note over czf: POST :/api/v3/upload
		fo->>fo: Decode JWT
		fo-->>-czf: return 200 or 401 depend to decode action
````

Infos complémentaires : 
- les fronts s'occupent de générer le QR-code (dans ce cas, l'étape du Fetch generate QR-Code n'est pas necessaire)
- Si ils ne peuvent pas le faire (alors on garde l'étape du Fetch generate QR-Code)

Payload du JWT token : 
````json
{
    "user_id": 1,
    "upload_outside_session": true,
    "token": nil,
    "expired_at": "" //iso8601
}
````

Objet de réponse de Photo (sortie de Fotom):
````json
{
    sha1: object.sha1,
    width_px: object.width_px,
    height_px: object.height_px,
    provider_tag: object.provider_tag,
    upload_outside_session: true or flase
    taken_at: object.taken_at,
    updated_at: object.updated_at,
}

````

Payloads responses :
```
POST : /api/v2/identified/:lang/upload_photos_token
{
	"token": "EB9B0AD1-9F63-4662-A0E9-C397BAEEC45C",
	"expired_at": "" //iso8601
}
POST : /api/v3/upload
HEADER : 
	- Authorization Bearer :jwt_token
// Payload is the same like v2 upload 
```

