Noizu.Slack.Files (Noizu.Slack v0.1.0)

Copy Markdown View Source

File uploads via Slack's external upload flow (the legacy files.upload method is retired):

  1. files.getUploadURLExternal (filename, length) → upload_url, file_id
  2. the bytes are sent to upload_url (no bot token — the URL is pre-signed)
  3. files.completeUploadExternal (files, channel_id, initial_comment, thread_ts) shares the file
Files.upload(client, "C123", %{filename: "report.csv", content: csv, title: "Report"})
Files.upload(client, "C123", %{path: "/tmp/chart.png", thread_ts: ts})

Pass channel = nil to upload without sharing.

Options

  • :upload_method — HTTP method for step 2: :post (default, per Slack docs) or :put.
  • :alt_txt, :snippet_type — forwarded to step 1.
  • request keys :token, :headers as for every call.

Summary

Functions

POST files.getUploadURLExternal → upload → files.completeUploadExternal — uploads and shares a file.

Types

upload()

@type upload() :: %{
  optional(:filename) => String.t(),
  optional(:content) => iodata(),
  optional(:path) => Path.t(),
  optional(:title) => String.t(),
  optional(:initial_comment) => String.t(),
  optional(:thread_ts) => String.t()
}

Functions

upload(client, channel, file, opts \\ [])

POST files.getUploadURLExternal → upload → files.completeUploadExternal — uploads and shares a file.