reworked image uploareworked image upload

Please enter the commit message for your changes. Lines starting
This commit is contained in:
nek0 2014-08-17 23:01:25 +02:00
parent 88fc9feae7
commit 07e9f9a213
2 changed files with 9 additions and 4 deletions

View file

@ -37,7 +37,7 @@ postUploadR = do
((result, uploadWidget), enctype) <- runFormPost (uploadForm userId)
case result of
FormSuccess temp -> do
path <- writeOnDrive $ tempMediumFile temp
path <- writeOnDrive (tempMediumFile temp) userId (tempMediumAlbum temp)
medium <- return $ Medium
(tempMediumTitle temp)
path
@ -56,10 +56,13 @@ postUploadR = do
setMessage "You need to be logged in"
redirect $ LoginR
writeOnDrive :: FileInfo -> Handler FilePath
writeOnDrive file = do
writeOnDrive :: FileInfo -> UserId -> AlbumId -> Handler FilePath
writeOnDrive file userId albumId = do
filename <- return $ fileName file
path <- return $ "static" </> (unpack filename)
path <- return $ "data"
</> (unpack $ extractKey userId)
</> (unpack $ extractKey albumId)
</> (unpack filename)
liftIO $ fileMove file path
return path

View file

@ -7,6 +7,8 @@
<a href=@{LogoutR}>Logout
<li>
<a href=@{NewAlbumR}>Create album
<li>
<a href=@{UploadR}>Upload image
$nothing
<li>
<a href=@{LoginR}>Login