Skip to main content

Attachments

Upload and attach one local file to an issue:

linear-cli attachment upload --issue ENG-123 --file ./screenshot.png
linear-cli attachment upload --issue ENG-123 --file ./report.pdf --title "Bug report"

The flags are:

FlagRequiredBehavior
--issue <identifier>YesIssue identifier such as ENG-123; it is resolved to a Linear issue ID.
--file <path>YesLocal file path. The entire file is read before upload.
--title <text>NoAttachment title; defaults to the base filename.

The implementation performs these steps:

  1. Detect the filename, byte size, and MIME type. A known extension wins; otherwise http.DetectContentType inspects the bytes.
  2. Call Linear's fileUpload mutation to receive uploadUrl and assetUrl.
  3. Send the bytes with HTTP PUT to the presigned URL, setting Content-Type and Content-Length. This request has a 60-second timeout.
  4. Call attachmentCreate with the issue ID, title, and asset URL.

The success envelope's data object contains attachment, assetUrl, fileName, fileSize, contentType, and issueIdentifier. Missing flags and local file read failures return usage errors with exit code 2; upload connection failures return NETWORK_ERROR / 6.