working on upload

This commit is contained in:
nek0 2014-08-13 19:34:42 +02:00
parent 56c1731d64
commit 3dc4bf631a
2 changed files with 7 additions and 5 deletions

View file

@ -34,7 +34,7 @@ postUploadR = do
((result, uploadWidget), enctype) <- runFormPost (uploadForm username)
case result of
FormSuccess temp -> do
path <- writeOnDrive $ tempMediumFile temp
path <- writeOnDrive username $ tempMediumFile temp
medium <- return $ Medium
(tempMediumTitle temp)
path
@ -52,8 +52,8 @@ postUploadR = do
setMessage $ [shamlet|<pre>You need to be logged in|]
redirect $ LoginR
writeOnDrive :: FileInfo -> Handler FilePath
writeOnDrive file = do
writeOnDrive :: Text -> FileInfo -> Handler FilePath
writeOnDrive username file = do
filename <- return $ fileName file
path <- return $ "static" </> (unpack filename)
liftIO $ fileMove file path

View file

@ -1,6 +1,8 @@
$if null recentMedia
<p>This gallery is still empty.
$else
$forall (Entity mediaId medium) <- recentMedia
$forall (Entity mediumId medium) <- recentMedia
<div class="thumbnails">
<div class="single">
<a href=#{mediumPath medium}>
<img src=#{mediumPath medium}><br>
#{mediumTitle medium}