Upload Store
Persist multipart identity and resume after the user reselects the same file.
An UploadStore persists multipart metadata, not the browser File. After a
reload, the user reselects the same local file and the client uses the stored
identity to reconcile parts and resume.
import { createLocalStorageStore } from "@dimah-s3/react";
export const localStorageStore = createLocalStorageStore();"use client";
import { useUpload } from "@dimah-s3/react";
import { localStorageStore } from "@/lib/upload-store";
export function VideoUploader() {
const upload = useUpload({
route: "video",
multipart: true,
uploadStore: localStorageStore,
});
return (
<div
{...upload.getRootProps()}
className="cursor-pointer rounded border p-4 text-center"
>
<input {...upload.getInputProps()} />
{upload.isUploading
? `Uploading: ${upload.progress.percent}%`
: "Upload large video"}
</div>
);
}The resume key is derived as
${route}:${file.name}:${file.size}:${file.lastModified}. It is a lookup key,
not a collision-resistant hash.
Built-in stores
createLocalStorageStore()— persists multipart metadata in browserlocalStorageacross page reloads.createMemoryStore()— in-memory store for unit tests or SSR.
import { createLocalStorageStore, createMemoryStore } from "@dimah-s3/react";
const memoryStore = createMemoryStore();
const localStore = createLocalStorageStore();Custom upload store interface
import type { UploadStore } from "@dimah-s3/react";Prop
Type
Frequently asked questions
No. @dimah-s3/db tracks pending uploads on the server, while an
UploadStore maps a browser-side resume identity to the S3 key and upload ID.
Use createLocalStorageStore() for same-browser reloads, or implement the
custom store interface with your own API for
cross-device metadata lookup. In either case, the browser still needs the user
to select the same local file.
Enable uploadStore for large multipart uploads that users may need to resume
after a refresh or lost connection. After a reload they must reselect the same
file. Small, single-part uploads do not need a store.