To edit a record that already has files, pass their stored URLs to the file uploader as defaultValue. Each becomes a finished item, with a preview for images, that can be removed like any other. onUrlsChange gives back the URLs to save: the ones left plus the new uploads.

Drag and drop, or browseimage/* · max 4 files
  • Preview of avatar.jpgavatar.jpgUploaded

Saves images: /samples/avatar.jpg

The record starts with one stored image. Remove it, or add another: the line under the uploader shows what the form would save.

From URLs to items

defaultValue takes stored URLs, File objects or full items. A URL becomes an item that is already done:

  • Its name is the last part of the URL path, decoded.
  • Its type is guessed from the extension, so a .jpg, .png, .webp or other image extension shows a preview. Anything else shows the file glyph.
  • Its size is unknown, so none is shown. It has no file, so it cannot be retried.

defaultValue is read once, when the uploader mounts. To change the items later, control them with value and onValueChange.

Saving

onUrlsChange is called after every change with the URLs of the stored items and of the finished uploads, in list order. A file still uploading has no URL yet, so it joins the list when it finishes. That array is what a record usually keeps.