diff --git a/Handler/Upload.hs b/Handler/Upload.hs index 66e913d..eb32ada 100644 --- a/Handler/Upload.hs +++ b/Handler/Upload.hs @@ -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 diff --git a/templates/default-layout.hamlet b/templates/default-layout.hamlet index 7f7f940..281180b 100644 --- a/templates/default-layout.hamlet +++ b/templates/default-layout.hamlet @@ -7,6 +7,8 @@ Logout
  • Create album +
  • + Upload image $nothing
  • Login