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

View file

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