postFileNewR' :: AssetId -> Handler RepHtml
postFileNewR' aid = do
  _asset <- runDB $ get404 aid
  user <- requireAuth
  ((result, formWidget), formEnctype) <- runFormPost fileUploadForm
  case result of
    FormSuccess (fi,info) -> do
                 fn <- liftIO randomFileName
                 liftIO (LBS.writeFile fn (fileContent fi))
                 let crc = crc32 (fileContent fi)
                 fsize <- liftIO $ getFileSize fn
                 let newFile = File aid (entityKey user) fn info (fileName fi) (fileContentType fi) fsize crc
                 fid <- runDB $ insert newFile
                 redirect (FileViewR fid)
    _ -> return ()

  defaultLayout $ do
       setTitle "Upload new file."
       $(widgetFile "file/new")
postFileNewR' :: AssetId -> Handler RepHtml
postFileNewR' aid = do
  _asset <- runDB $ get404 aid
  user <- requireAuth
  ((result, formWidget), formEnctype) <- runFormPost fileUploadForm
  case result of
    FormSuccess (fi,info) -> do
                 fn <- liftIO randomFileName
                 liftIO (LBS.writeFile fn (fileContent fi))
                 let crc = crc32 (fileContent fi)
                 fsize <- liftIO $ getFileSize fn
                 let newFile = File aid (entityKey user) fn info (fileName fi) (fileContentType fi) fsize crc
                 fid <- runDB $ insert newFile
                 redirect (FileViewR fid)
    _ -> return ()

  defaultLayout $ do
       setTitle "Upload new file."
       $(widgetFile "file/new")
postFileNewR' aid = do
  _asset <- runDB $ get404 aid
  user <- requireAuth
  ((result, formWidget), formEnctype) <- runFormPost fileUploadForm
  case result of
    FormSuccess (fi,info) -> do
                 fn <- liftIO randomFileName
                 liftIO (LBS.writeFile fn (fileContent fi))
                 let crc = crc32 (fileContent fi)
                 fsize <- liftIO $ getFileSize fn
                 let newFile = File aid (entityKey user) fn info (fileName fi) (fileContentType fi) fsize crc
                 fid <- runDB $ insert newFile
                 redirect (FileViewR fid)
    _ -> return ()

  defaultLayout $ do
       setTitle "Upload new file."
       $(widgetFile "file/new")