Skip to content

Document the content type header for the files API #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
skel of content type
  • Loading branch information
philkra committed Apr 26, 2024
commit 1499e62a2740af6f74614e4618453de152c77789
27 changes: 27 additions & 0 deletions 040-Data-operations/150-file-attachments.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,33 @@ curl --request PUT 'https://{workspace}.{region}.upload.xata.sh/db/{db}:{branch}

</TabbedCode>

Upload a file and set the `content-type`:

<TabbedCode tabs={['TypeScript', 'Python', 'cURL']}>
```ts
await xata.files.upload({ table: 'table_name', column: 'column_name', record: 'record_id' }, file);
```

```python
# file_content = bytes
response = xata.files().put(
"table_name",
"record_id",
"column_name",
file_content,
"image/jpeg" # set the content type
)
```

```sh
curl --request PUT 'https://{workspace}.{region}.upload.xata.sh/db/{db}:{branch}/tables/{table}/data/{record_id}/column/{column_name}/file' \
--header 'Content-Type: image/jpeg' \
--header 'Authorization: Bearer xau_REDACTED' \
--data-binary '@/path/to/file'
```

</TabbedCode>

### Append a file to an array using file APIs

Column type is `file[]` (file array).
Expand Down