Service for uploading images to any S3 compatible storage inspired from ospry and cloudinary.
The upload flow lets developers make cross-browser uploads directly to configured S3 cloud storage. When an image and it's transformations successfully uploaded, Louis sends back metadata about the image. The metadata can be used immediately, or sent up to your own server for claiming. In future version, unclaimed images will be deleted.

Request:
POST /upload
Headers:
Authorization: LOUIS_PUBLIC_KEY
Content-Type: multipart/form-data
Multipart body:
file: image
tags: tag1, tag2, tag3
key: "name of image[optional/usefull on migration]"
Response:
{
"error": "",
"payload": {
"key": "bdaqolfvn27g83tpe1s0",
"originalUrl": "https://bucketname.hb.bizmrg.com/bdaqolfvn27g83tpe1s0/original.jpg",
"transformations": {
"original": "https://bucketname.hb.bizmrg.com/bdaqolfvn27g83tpe1s0/original.jpg",
"super_transform": "https://bucketname.hb.bizmrg.com/bdaqolfvn27g83tpe1s0/super_transform.jpg"
}
}
}
Request:
POST /claim
Headers:
Authorization: LOUIS_SECRET_KEY
Content-Type: application/json
Body:
{
"keys": ["bd35b7n03vdv2aen0", "oeuaoeuhstbksu234"]
}
Response:
{
"error": "",
"payload": "ok"
}
Request:
POST /uploadWithClaim
Headers:
Authorization: LOUIS_SECRET_KEY
Content-Type: multipart/form-data
Multipart body:
file: image
tags: tag1, tag2, tag3
key: "name of image[optional/usefull on migration]"
Response the same as in /upload
./louis --env=<default: .env | path to file with environment variables> \
--transforms-path=<default: ensure-transforms.json | path to file containing json description of transforms> \
--initdb=<default: true | ensure needed tables in database>
docker run kexpress/louis
S3_BUCKET=<name of S3 bucket>
S3_ENDPOINT=https://hb.bizmrg.com <url to S3 api server; if not set used AWS endpoint by default>
AWS_REGION=ru-msk<region where s3 is stored>
AWS_ACCESS_KEY_ID=<your S3 access key id>
AWS_SECRET_ACCESS_KEY=<your S3 secret key>
LOUIS_PUBLIC_KEY=<key used for uploading images>
LOUIS_SECRET_KEY=<key used for claiming images>
REDIS_URL=:6379
CLEANUP_DELAY=1 <delay in minutes after which not claimed images will be deleted>
CLEANUP_POOL_CONCURRENCY=10 <number of concurrent cleanup gorutines>
POSTGRES_ADDRESS=127.0.0.1:5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=1234
POSTGRES_DATABASE=postgres
POSTGRES_SSL_MODE=disable <disable/enable>
MAX_IMAGE_SIZE=5242880 <in bytes>
CORS_ALLOW_ORIGIN=*
CORS_ALLOW_HEADERS=Authorization,Content-Type,Access-Content-Allow-Origin
THROTTLER_QUEUE_LENGTH=10 <max parallel uploads>
THROTTLER_TIMEOUT=15s <queued request will be rejected after this delay with 503 status code>
MEMORY_WATCHER_ENABLED=false <if true then once in interval debug.FreeOsMemory() will be called if current RSS is more than limit>
MEMORY_WATCHER_LIMIT_BYTES=1610612736 <maximum memory amount ignored by watcher, default is 1.5GB>
MEMORY_WATCHER_CHECK_INTERVAL=10m
If you have problems with installing dependencies or building project. It's highly probably that they caused by h2non/bimg. Please check prerequisites and installation guides for these libs.
# libvips is needed in order to install bimg
go get -v ./...
go build ./cmd/louis
./louis
For development purposes(e.g. for running test) is better to use docker containers with databases:
docker run -d --rm -v $(PWD)/data/pg:/var/lib/postgresql/data -e POSTGRES_PASSWORD=1234 -e POSTGRES_USER=postgres -p 5433:5432 --name pg-app postgres
docker run -d --rm -v $(PWD)/data/rd:/data -p 6379:6379 --name rds redis
Metrics are exposed in port 8001 and route /metrics
Content type
Image
Digest
Size
97.6 MB
Last updated
almost 7 years ago
docker pull kexpress/louis