Storehouse.File (Storehouse v0.1.0)

Copy Markdown View Source

A stored file: what Storehouse.store/2 gives, and what an app keeps in its records (or a document's data) to show and serve it again.

  • :key - its key in the store (Storehouse.key/2).
  • :url - its URL, from the store.
  • :name - the client's file name, for display only (Storehouse.clean_name/1).
  • :content_type - the type its bytes prove (Storehouse.Check).
  • :bytes - its size.
  • :width and :height - an image's, as a browser draws it (turned as a JPEG's EXIF says), or nil.
  • :checksum - the SHA-256 of its bytes, in Base64 (as S3's x-amz-checksum-sha256): the store checked it as it took the file, and Storehouse.checksum/1 gives it of a copy, to compare. nil for a file uploaded straight to a store that keeps none (Storehouse.verify_upload/2).
  • :preview - the URL of a smaller image of it (a thumbnail, a PDF's first page, a video's poster), when the app made one, or nil.

Summary

Functions

Whether the file is an image (PNG, JPEG, GIF or WebP).

Types

t()

@type t() :: %Storehouse.File{
  bytes: non_neg_integer(),
  checksum: String.t() | nil,
  content_type: String.t(),
  height: pos_integer() | nil,
  key: Storehouse.Adapter.key(),
  name: String.t(),
  preview: String.t() | nil,
  url: String.t(),
  width: pos_integer() | nil
}

Functions

image?(file)

@spec image?(t()) :: boolean()

Whether the file is an image (PNG, JPEG, GIF or WebP).