Image server
The image server is a simple nodejs express server that allows images to be uploaded with Multer and resizes the based on url scheme, resizing is done with the node-steam library.
See: https://github.com/Amsterdam/openstad-image-server
Http-bearer is used fo validating requests so only registered clients can upload images.
Knex migrations create the clients table for registering clients that are allowed to use the API.
Prerequisites
Installation
1. Run npm install
2. Configure .env
For throttle see options in node-steam.
The app url is used to return a full url after upload.
Images directory defaults to images, if doesn't get created, create it manually.
3. Install knex globally
4. Run knex migration
5. Add a client to mysql
6. Run the server
Run npm (or pm2, or whatever runner you use).
Clients
For every site create a row in the MySQL clients table. Generate a random token that's safe. Currently there is no interface for creating so create it command line or through an mysql interface like sequelpro or phpmyadmin. The seed will generate one if the ENV values is
Uploading an image
Example with node.js, using node-fetch & form-data. Pass the access_token that you've generated for the client, can be in url or as header "Bearer: ${token}" make sure it's over HTTPS.
Displaying & Resizing image
Example for creating a thumbnail resize and crop:
For all options (resizing, cropping, filter, etc) check node-steam.
Last updated