How to upload a file to Linear
This guide shows you how to upload a file to Linear while using the GraphQL API or TypeScript SDK.
Files uploaded to Linear are stored in Linear's private cloud storage. They are only intended to be used within Linear, and you must authenticate to access these files elsewhere. Read more in File Storage Authentication
Include an image within markdown content
The easiest way to upload an image to Linear's private cloud storage is to include a URL reference to it within markdown content that you provide while creating issues, comments, or documents.
For example, while using the IssueCreate
mutation in the GraphQL API, include an image in the markdown content provided in the description
field:
The image file at https://example.com/image.png
will be automatically uploaded to Linear's private cloud storage. You can also embed a base64 encoded image instead of a URL:
Note that images in markdown must be surrounded by newlines to be parsed correctly. This approach only works for image files.
Upload files manually
To upload directly to storage and for files other than images, use the fileUpload
mutation to request a pre-signed upload URL, then send a PUT
request to that URL with the file content.
Attempting to upload a file from the client-side will be blocked by Linear's Content Security Policy (CSP). You may request the signed upload URL from the client, but the PUT
request must be executed on the server.
Here is an example using the TypeScript SDK to upload a file on the server:
The resulting file URL now points to Linear's private cloud storage and can be used in API mutations, like creating an issue or a comment.
Proxy the file upload on the server
If you're handling file uploads from a website, for example with the <input type="file" />
element, you must forward the file to a server before attempting to upload it to Linear.
Next.js Example
Browse or run a full example that proxies a file upload through Next.js API Routes here: https://github.com/linear/linear/tree/master/examples/nextjs-file-upload
Errors
Common errors when uploading files to Linear and how to fix them.
Last updated