Using prisma to create a new record with a file column
How do I use the prisma client to create a new record with an empty file column? I've tried the following:
1. Placeholder metadata (taking hints from this example: https://xata.io/docs/sdk/file-attachments#1-createupdate-a-record-with-an-empty-file-server-side)
2. Empty object:
For each case I get the error:
What is the correct format?
3 Replies
@kostas Please help?
Hi, File columns are a Xata-specific type and only work over the REST API. You cannot read/write to them properly via Prisma unfortunately.
You'll need to use the Xata TS SDK to interface with File/File[] columns. Prisma cannot write to them in the proper format.
There is an intermediate service sitting between Postgres and the REST API that manages File column metadata, urls, content validation etc. Prisma talks to Postgres directly, which isn't the appropriate endpoint for Files.
We're actively working to make File columns work directly within Postgres, there is a refactoring in progress. In the meantime, File columns should only be touched by the TS SDK.
Okay, that's great to know. Thanks for the explanation!