------------------------------------------------------------------------------ -- | This module contains primitives and helper functions for handling -- requests with @Content-type: multipart/form-data@, i.e. HTML forms and file -- uploads. -- -- Typically most users will want to use 'handleFileUploads', which writes -- uploaded files to a temporary directory before sending them on to a handler -- specified by the user. -- -- Users who wish to handle their file uploads differently can use the -- lower-level interface called 'handleMultipart'. That function takes -- uploaded files and streams them to a consumer of the user's choosing. -- -- Using these functions requires making \"policy\" decisions which Snap can't -- really make for users, such as \"what's the largest PDF file a user is -- allowed to upload?\" and \"should we read form inputs into the parameters -- mapping?\". Policy is specified on a \"global\" basis (using -- 'UploadPolicy'), and on a per-file basis (using 'PartUploadPolicy', which -- allows you to reject or limit the size of certain uploaded -- @Content-type@s). -- -- Example usage: -- -- @ -- {-\# LANGUAGE OverloadedStrings #-} -- -- module Main where -- -- import qualified Data.ByteString.Char8 as B8 -- import Data.Functor ((\<$>)) -- import "Snap.Core" ('Snap.Core.Snap', 'Snap.Core.route', 'Snap.Core.writeBS') -- import Snap.Http.Server (quickHttpServe) -- import "Snap.Util.FileUploads" -- import System.Posix (FileOffset, fileSize, getFileStatus) -- -- uploadForm :: 'Snap.Core.Snap' () -- uploadForm = 'Snap.Core.writeBS' \"\