#media update

7 messages · Page 1 of 1 (latest)

vital badge
#

what is the api to patch media, i have done this but getting internal error 500:

const updatedDoc = {
...doc,
status,
};

  console.log("Updated Document with Status:", updatedDoc);
  const statusResponse = await fetch(`/api/media/${docId}`, {
    credentials: 'include',
    method: 'PATCH',
    body: JSON.stringify({ updatedDoc }), 
    headers: {
      'Content-Type': 'application/json',
    },
  });
vital badge
#

@ember reef

ember reef
#

@vital badge What does the command line say?

vital badge
#

it says file is undfined:

[00:47:47] ERROR (payload): TypeError: Cannot destructure property 'file' of 'undefined' as it is undefined.
at map (/Users/hashim/Documents/GitHubCore/alkina/node_modules/payload/src/uploads/unlinkTempFiles.ts:28:40)
at Array.map (<anonymous>)
at mapAsync (/Users/hashim/Documents/GitHubCore/alkina/node_modules/payload/src/utilities/mapAsync.ts:5:26)

#

i tried defining a "file" field and including that as well in the patch request

#

for reference this is the "updatedDoc" being passed in the PATCH req:
{
"id": "679366a4a15adb9ba3ec4a4a",
"status": "requested",
"filename": "CN-2 Consumer Notice-3.pdf",
"mimeType": "application/pdf",
"filesize": 172296,
"createdAt": "2025-01-24T10:08:36.728Z",
"updatedAt": "2025-01-24T19:47:47.657Z",
"url": "http://localhost:3000/media/CN-2 Consumer Notice-3.pdf"
}