reworked image uploareworked image upload
Please enter the commit message for your changes. Lines starting
This commit is contained in:
parent
88fc9feae7
commit
07e9f9a213
2 changed files with 9 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue