File upload with Snap
File upload is a very basic HTTP operation handled through Content-type: multipart/form-data. In this recipe, we will create an HTML form and upload a file through it. While the file is being uploaded, we will dynamically process the contents, and report the summary.
How to do it...
- Create a new project,
file-upload, with asimplestack template:
stack new file-upload simple
- Add a dependency on the
snap-corelibrary in thebuild-dependssubsection of theexecutablesection, as follows:
executable file-upload
hs-source-dirs: src
main-is: Main.hs
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
, snap-core
, snap-server
, heist
, snap
, lens
, bytestring
, io-streams
, text- Use the following command to solve the constraints...