This is a photo hosting service intended for StreetComplete, but it could also be used by other applications.
Abuse is prevented by requiring an association between an uploaded photo and an open, publicly visible OpenStreetMap note. If the associated note is closed or deleted, photo(s) associated with the note are also removed.
Therefore, the software queries the OSM API and parses photo URLs out of notes.
Programming language, repository structure and other design decisions are based on the requirements imposed by the intended hosting infrastructure for StreetComplete.
Requires PHP 5.6 or later.
A cleanup cron job periodically fetches notes associated with photos and checks if the note is closed or if the URL vanished (moderated). Photos which are no longer necessary are deleted after a configurable delay. It is also possible to specify a maximum storage size, which, when exhausted, will lead to the deletion of the oldest photos.
.htaccess
file is not usedconfig.php
from config.sample.php
template and fill with production settingscleanup.php
scriptIn order to upload a photo, POST a request to upload.php
that contains the raw file data in the body.
On success, it returns a JSON response including the URL where the photo will be reachable once it got activated:
{'future_url': 'https://example.org/pics/42.jpg'}
On failure, the JSON will contain an error key, f.e.:
{'error': 'File type not allowed'}
To activate photos contained in a certain OSM note, POST a request to activate.php
, giving it the note ID:
{"osm_note_id": 1337}
On success, it will return a JSON with information about the number of found and activated photo URLs:
{'found_photos': 2, 'activated_photos': 1}
On failure, the JSON will contain an error key, e.g.:
{'error': 'Error fetching OSM note'}
In StreetComplete, the following class communicates with the mentioned API, you can take this as an example