Skip to content
This repository was archived by the owner on Jan 30, 2022. It is now read-only.
/ aufi Public archive

An Image Upload, Delivery and Resizing Service

License

Notifications You must be signed in to change notification settings

stalefruits/aufi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aufi Build Status

aufi is a service for image upload, retrieval and resizing.

Setup

Configuration

Aufi takes its configuration from either the environment variable EDN_CONFIG or a file. In both cases data is expected to be an EDN map as outlined in aufi.system.config with the minimal configuration being:

{:s3 {:bucket "aufi-production-01"}}

AWS credentials are fetched using the DefaultAWSCredentialsProviderChain.

Running the Service

Aufi can be bundled as an Uberjar using:

$ lein uberjar

Afterwards, it can be started directly, e.g.:

$ java -Xmx256m -Xms256m -jar aufi-standalone.jar "config.edn"
09.08.2016 17:47:54.705 [sfys] [aufi.system.httpd] INFO  - server is running on 0:9876 ...
...

Alternatively, the service can be run from the REPL:

(require '[aufi.core :as aufi])
(aufi/start "config.edn")

In both cases, if the config file is omitted (or given as nil) the environment variable EDN_CONFIG will be accessed.

Logging

Aufi uses SLF4J for logging and includes Logback as its implementation. An example of a configuration file can be found at resources/logback-dev.xml.

Alternatively, you can replace Logback with an SLF4J-compatible logger of your choice.

Usage

Upload

Images can be uploaded using a POST request to /v1/images. Image data should be sent in the request body without any preprocessing or extra encoding; cf. curl's -d and --data-binary options.

$ curl -i http://localhost:9876/v1/images --data-binary @image.jpg
HTTP/1.1 100 Continue

HTTP/1.1 201 Created
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location
Date: Tue, 09 Aug 2016 16:18:21 GMT
Location: /v1/images/e7cb0532-98f1-4d57-825f-c66765d3a4a6
Server: Aleph/0.4.1
Content-Length: 0
Connection: keep-alive

The uploaded image is now available at the path returned in the Location header.

Download

Aufi offers the following query parameters to control scaling of the requested image:

  • max-width
  • max-height
  • width
  • height

They can be combined to achieve the following results:

max-height height none
max-width scale into width/height bounds scale down to maximum width
width crop centrally to exact dimensions scale exactly to given width
none scale down to maximum height scale exactly to given height original image

Filenames

Aufi allows you to add any kind of path after the image location, so the following URIs point at the same image:

/v1/images/e7cb0532-98f1-4d57-825f-c66765d3a4a6
/v1/images/e7cb0532-98f1-4d57-825f-c66765d3a4a6/cat-trapped-in-monad

This can be useful to tackle e.g. some SEO requirements.

Health Check

The service health can be checked via one of the following paths:

  • /_status?timeout=N
  • /_status

The default timeout is 1000, representing 1000ms.

Developing and Contributing

Contributions are always welcome. Please take a look at our Contribution Guidelines for a quick overview of how your changes can best make it to master.

License

Copyright © 2016 stylefruits GmbH

This project is licensed under the Apache License 2.0.

About

An Image Upload, Delivery and Resizing Service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published