Bring Your Own Backend
Delete
Delete one or many objects through your custom backend.
Deletion is a direct backend mutation, not a presigned client-to-S3 transfer.
Delete one
delete receives a route and one object key.
Prop
Type
Prop
Type
import type { DeletePayload, DeleteResponse } from "@dimah-s3/core";Example
Add this to the defineApi skeleton.
@dimah-s3/server uses DELETE /api/s3/delete?route=…&key=….
async delete(payload) {
const params = new URLSearchParams({
route: payload.route,
key: payload.key,
});
const res = await fetch(`/api/files/delete?${params}`, { method: "DELETE" });
if (!res.ok) throw new Error(await res.text());
return res.json();
}Delete many
deleteMany receives one route and between 1 and 100 keys. Return one result
for every input key so the React hook can preserve partial successes and expose
per-object errors.
Prop
Type
Prop
Type
import type { DeleteBatchPayload, DeleteBatchResponse } from "@dimah-s3/core";async deleteMany(payload) {
const res = await fetch("/api/files/delete-batch", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
if (!res.ok) throw new Error(await res.text());
return res.json();
}