Storage.Uploader (PhoenixContribStorage v0.1.0)

View Source

Handles file uploads and creates blobs.

Summary

Functions

Uploads a file and creates a blob record.

Same as put/2 but raises on error.

Functions

put(file_data, opts \\ [])

Uploads a file and creates a blob record.

Options

  • :filename - The original filename (required)
  • :content_type - MIME type of the file (inferred from filename if not provided)
  • :service_name - Storage service to use (defaults to configured default)
  • :metadata - Additional metadata to store with the blob

Examples

# Upload from file path
Storage.Uploader.put("/path/to/file.jpg", filename: "avatar.jpg")

# Upload binary data
Storage.Uploader.put(file_binary, 
  filename: "document.pdf", 
  content_type: "application/pdf"
)

# Upload with metadata
Storage.Uploader.put(file_data, 
  filename: "image.jpg",
  metadata: %{alt_text: "Profile picture", user_id: 123}
)

put!(file_data, opts \\ [])

Same as put/2 but raises on error.