robotmay / s3-direct-file-upload / S3DirectFileUpload

Module for working with Shrine.rb and S3-compatible APIs for direct file uploads

Definition


type alias FileUpload =
{ id : String
, storage : String
, metadata : Metadata 
}

Represents an uploaded file. This is what will be returned by upload on success.


type alias Metadata =
{ size : Basics.Int
, filename : String
, mime_type : String 
}

A substructure returned as part of the FileUpload data.

Upload a file

upload : File -> String -> Task Http.Error FileUpload

Upload a file, using a signing endpoint provided by Shrine.

The signingEndpoint is "/s3/params" by default when Shrine is set up on a Ruby on Rails application, but should be used without the preceding slash here, e.g. "s3/params"

Optional public decoders if you need them

fileUploadDecoder : Json.Decode.Decoder FileUpload

A decoder for building a FileUpload value from JSON. This isn't actually used in this module but it's provided for convenience.

metadataDecoder : Json.Decode.Decoder Metadata

A decoder for building a Metadata value from JSON. This isn't actually used in this module but it's provided for convenience.