Global Key-Value Store.beta

Images

gokv will treat uploaded files as images when the Content-Type starts with image/ (exclude svg), then store, resize, and optimize images at scale.

import gokv from "https://deno.land/x/gokv@0.0.23/mod.ts";

const fs = gokv.FileStorage();
const imageFile = new File(
  [await Deno.readFile("./image.png")],
  "image.png",
  { type: "image/png" },
);
const { url } = await fs.upload(imageFile); // url -> https://img.gokv.io/xxx-xxx-xxx-xxx

Resizing uploaded images

Your uploaded images will be resized in 1920x1080 boundary by default. You can resize them with gokv resizing presets:

  • https://img.gokv.io/xxx-xxx-xxx-xxx (Default, resizng by 1920x1080 boundary)
  • https://img.gokv.io/xxx-xxx-xxx-xxx/4k (Resizng by 3840x2160 boundary)
  • https://img.gokv.io/xxx-xxx-xxx-xxx/thumb1024 (Resizng by 1024x1024 boundary)
  • https://img.gokv.io/xxx-xxx-xxx-xxx/thumb512 (Resizng by 512x512 boundary)
  • https://img.gokv.io/xxx-xxx-xxx-xxx/thumb256 (Resizng by 256x256 boundary)
  • https://img.gokv.io/xxx-xxx-xxx-xxx/thumb128 (Resizng by 128x128 boundary)
  • https://img.gokv.io/xxx-xxx-xxx-xxx/thumb64 (Resizng by 64x64 boundary)

Image will be shrunk in size to fully fit within the given width or height, but won’t be enlarged.

Optimize images automatically

img.gokv.io delivers images with modern image format if the Accept header from the browser includes AVIF or WebP which is significantly smaller.

Accept: image/avif,image/webp,image/*,*/*;q=0.8