© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
ImmichI
Immich•13mo ago•
7 replies
SkepticMystic

How to POST /assets

Hi there,
I'm trying to upload an asset using
POST /assets
POST /assets
. I can't figure out how to send the file data, however. Currently, my code looks like this:
const upload = (body: {
    file: File;
  }) => {
    const form = new FormData();

    const uuid = crypto.randomUUID();
    const now = new Date().toISOString();

    form.set("assetData", body.file);
    form.set("deviceId", uuid);
    form.set("deviceAssetId", uuid);
    form.set("fileCreatedAt", now);
    form.set("fileModifiedAt", now);

    return request("/assets", {
      body: form,
      method: "POST",
      headers: {
        Accept: "application/json",
        "Content-Type":
          "multipart/form-data; boundary=---WebKitFormBoundary7MA4YWxkTrZu0gW",
      },
    });
  }
const upload = (body: {
    file: File;
  }) => {
    const form = new FormData();

    const uuid = crypto.randomUUID();
    const now = new Date().toISOString();

    form.set("assetData", body.file);
    form.set("deviceId", uuid);
    form.set("deviceAssetId", uuid);
    form.set("fileCreatedAt", now);
    form.set("fileModifiedAt", now);

    return request("/assets", {
      body: form,
      method: "POST",
      headers: {
        Accept: "application/json",
        "Content-Type":
          "multipart/form-data; boundary=---WebKitFormBoundary7MA4YWxkTrZu0gW",
      },
    });
  }


If I exclude the
Content-Type
Content-Type
header, I get a validation error saying the various fields are missing.
If I add
Content-Type: multipart/form-data
Content-Type: multipart/form-data
, I get a
Multipart: Boundary not found
Multipart: Boundary not found
error.
If I add
Content-Type: multipart/form-data; boundary=---WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Type: multipart/form-data; boundary=---WebKitFormBoundary7MA4YWxkTrZu0gW
, I get a
Multipart: Unexpected end of form
Multipart: Unexpected end of form
error.
I found that boundary value in a few places on the web, but it doesn't seem to work.

I'm not sure how to proceed. How do I upload an asset?
ImmichJoin
A place to hang out, get support, discuss Immich, get announcements about releases and anything else going on.
36,590Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

how to deal with very large assets?
ImmichIImmich / help-desk-support
3y ago
How to remove offline album assets? (timeline duplicates)
ImmichIImmich / help-desk-support
14mo ago
12 assets never upload for months. How to force?
ImmichIImmich / help-desk-support
2mo ago
Splitting assets due to misconfiguration
ImmichIImmich / help-desk-support
6mo ago