Skip to content

Latest commit

 

History

History
108 lines (83 loc) · 2.6 KB

api.md

File metadata and controls

108 lines (83 loc) · 2.6 KB

API

There are only two endpoints.

Process File

Send a POST to / with the following arguments.

Arguments:

  • file - Binary file data.
  • sizes - Array of file configurations to return.
    • width - Required. Max width for image.
    • height - Required. Max height for image.
    • fill - If true, resize and crop to width and height using the Lanczos resampling filter.
    • name - As no effect, but is returned with payload if provided for convenience.
[
  {
    "width": 1000,
    "height": 1000,
    "fill": false
  },
  {
    "width": 500,
    "height": 500,
    "fill": true
  }
]

At the moment, processing options are minimal based on our needs, but more could be added. Please submit a issue for PR for more features.

Example by cURL:

curl -X POST \
  http://localhost:31111/ \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F file=@_DSC1814.jpg \
  -F 'sizes=[{"name": "foobar", "width":100, "height": 100, "fill": false}]'

Response

The response objects will always be in the same order they were sent. The fileName property contains the new generated unqiue name for this file. This is the same value that should be stored and used to remove the file froms storage.

[
  {
    "fileName": "generatedname.jpg",
    "url": "https://the-public-url",
    "width": 1000,
    "height": 1000,
    "fill": true
  },
  {
    "fileName": "generatedname.jpg",
    "url": "https://the-public-url",
    "width": 500,
    "height": 500,
    "fill": true
  }
]

Note about the generated filename: The filename that Imageup generates is based on the following format: YYYY-MM-DD-HH-MM-SS-UUIDv4.<file format ext>. The UUIDv4 is generated using satori/go.uuid.

Remove files

Send a DELETE to / with the following argument.

Arguments:

  • files - A comma-delimited list of files. "file1, file2, etc"

Example by cURL:

curl -X DELETE \
  http://localhost:31111/ \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F 'files=foobar-82f100f-4bfd-4671-a0c1-9fc662782.jpg,foobar-38ef100f-4bfd-4671-a0c1-9fc667f2d924.jpg'

This will purge both files from the bucket.

Errors

The code will be a relevant http code.

{
    "code": 405,
    "message": "invalid"
}