I've gotten as far as figuring out how to use onInit() config option to run a script, and using the payload.create method from the docs, but I can't find any docs on how to use this with an Upload collection.
I've also found that the in the object supplied to
payload.create(), the
datafield has a
filesfield with type
fs.promises.FileHandle[]. I've passed this type to payload but I get:
    at new ExtendableError (/home/loz/projects/tf-api/node_modules/payload/src/errors/APIError.ts:26:11)
    at new APIError (/home/loz/projects/tf-api/node_modules/payload/src/errors/APIError.ts:43:5)
    at new MissingFile (/home/loz/projects/tf-api/node_modules/payload/src/errors/MissingFile.ts:7:5)
    at generateFileData (/home/loz/projects/tf-api/node_modules/payload/src/uploads/generateFileData.ts:51:35)
    at create (/home/loz/projects/tf-api/node_modules/payload/src/collections/operations/create.ts:110:77)
[nodemon] app crashed - waiting for file changes before starting...Hi @sibergenome - to use
payload.createon an upload-enabled collection you need to additionally define the
filePath, for example:
    collection: 'uploads',
    filePath: '/filepath',
    data: {...}
  });Thanks! That works perfect 🙂
Star
Discord
online
Get dedicated engineering support directly from the Payload team.