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)
|
((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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue