Drivers
HTTP
Use a remote HTTP/HTTPS endpoint as data storage.
Usage
Supports built-in http server methods.
This driver implements meta for each key including mtime
(last modified time) and status
from HTTP headers by making a HEAD
request.
import { createStorage } from "unstorage";
import httpDriver from "unstorage/drivers/http";
const storage = createStorage({
driver: httpDriver({ base: "http://cdn.com" }),
});
Options:
base
: Base URL for urls (required)headers
: Custom headers to send on all requests
Supported HTTP Methods:
getItem
: Maps to httpGET
. Returns deserialized value if response is okhasItem
: Maps to httpHEAD
. Returnstrue
if response is ok (200)setItem
: Maps to httpPUT
. Sends serialized value using bodyremoveItem
: Maps toDELETE
clear
: Not supported
Transaction Options:
headers
: Custom headers to be sent on each operation (getItem
,setItem
, etc)