CloudKit.Asset (cloud_kit v0.3.0)

Copy Markdown View Source

Asset upload and download functionality for CloudKit.

Summary

Functions

Download an asset from CloudKit.

Upload a file to CloudKit as an asset.

Functions

download(download_url, opts \\ [])

@spec download(
  String.t(),
  keyword()
) :: {:ok, binary()} | {:error, term()}

Download an asset from CloudKit.

Parameters

  • download_url: The signed download URL from an asset field
  • opts: Download options

upload(file_path, record_type, field_name, opts \\ [])

@spec upload(String.t(), String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Upload a file to CloudKit as an asset.

This is a two-step process:

  1. Get upload URL from CloudKit
  2. Upload the file content to that URL