Storehouse.Live.Writer (Storehouse v0.1.0)

Copy Markdown View Source

A LiveView upload writer (Phoenix.LiveView.UploadWriter) that streams each chunk on to the store as it comes, with no file on the app's disk: to S3 in the parts of a multipart upload, to the local disk in its place. Storehouse.Live.allow/3 with mode: :stream gives it to the upload.

It checks the file as it comes: its first bytes, once it has them, are of the type the browser claimed, of a type taken (:accept) and within :max_pixels, or the upload stops, and nothing of it stays in the store. Its checksum is computed on the way.

It runs in the upload's own process (a LiveView upload channel): a file's parts go to the store while the next chunks arrive, and the LiveView goes on meanwhile.