stHomeR :: Handler Html
postHomeR = do
  ((result, _), _) <- runFormPost uploadForm
  case result of
    FormSuccess fi -> do
      app <- getYesod
      fileBytes <- runResourceT $ fileSource fi $$ sinkLbs
      let mime = unpack $ fileContentType fi
      let fileAssoc = FileAssoc { fileAssocName = unpack $ fileName fi,
                                  fileAssocContents = fileBytes,
                                  fileAssocMime = mime,
                                  fileAssocType = parseFiletype mime,
                                  fileAssocId = 0 }
      addFile app fileAssoc
    _ -> return ()
  redirect HomeR


postHomeR :: Handler Html
postHomeR = do
  ((result, _), _) <- runFormPost uploadForm
  case result of
    FormSuccess fi -> do
      app <- getYesod
      fileBytes <- runResourceT $ fileSource fi $$ sinkLbs
      let mime = unpack $ fileContentType fi
      let fileAssoc = FileAssoc { fileAssocName = unpack $ fileName fi,
                                  fileAssocContents = fileBytes,
                                  fileAssocMime = mime,
                                  fileAssocType = parseFiletype mime,
                                  fileAssocId = 0 }
      addFile app fileAssoc
    _ -> return ()
  redirect HomeR
postHomeR = do
  ((result, _), _) <- runFormPost uploadForm
  case result of
    FormSuccess fi -> do
      app <- getYesod
      fileBytes <- runResourceT $ fileSource fi $$ sinkLbs
      let mime = unpack $ fileContentType fi
      let fileAssoc = FileAssoc { fileAssocName = unpack $ fileName fi,
                                  fileAssocContents = fileBytes,
                                  fileAssocMime = mime,
                                  fileAssocType = parseFiletype mime,
                                  fileAssocId = 0 }
      addFile app fileAssoc
    _ -> return ()
  redirect HomeR