Skip to content

Commit

Permalink
Fixed image upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Mar 1, 2020
1 parent c59e778 commit 5211c0b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions TurboHaskell/Controller/Param.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ data ImageUploadOptions = ImageUploadOptions { convertTo :: Text, imageMagickOpt



-- TODO: Rename to `uploadPng`
uploadFile :: _ => Proxy fieldName -> record -> IO record
uploadFile field user = uploadImageFile "png" field user
-- Usage: `user |> uploadPng #profilePicture`
uploadPng :: _ => Proxy fieldName -> record -> IO record
uploadPng field record = uploadImageFile "png" field record

uploadSVG :: _ => Proxy fieldName -> record -> IO record
uploadSVG = uploadImageFile "svg"
Expand All @@ -234,7 +234,7 @@ uploadImageWithOptions :: forall (fieldName :: Symbol) context record (tableName
uploadImageWithOptions options _ user =
let
ext = "jpg" :: Text
fieldName :: ByteString = cs (NameSupport.fieldNameToColumnName (cs (symbolVal (Proxy @fieldName))))
fieldName :: ByteString = cs (symbolVal (Proxy @fieldName))
tableName :: Text = cs (symbolVal (Proxy @tableName))
uploadDir :: Text = "static"
baseImagePath :: Text = "/uploads/" <> tableName <> "/" <> tshow (getField @"id" user) <> "/picture."
Expand Down Expand Up @@ -263,7 +263,7 @@ uploadImageFile :: forall (fieldName :: Symbol) context record (tableName :: Sym
) => Text -> Proxy fieldName -> record -> IO record
uploadImageFile ext _ user =
let
fieldName :: ByteString = cs (NameSupport.fieldNameToColumnName (cs (symbolVal (Proxy @fieldName))))
fieldName :: ByteString = cs (symbolVal (Proxy @fieldName))
tableName :: Text = cs (symbolVal (Proxy @tableName))
uploadDir :: Text = "static"
imagePath :: Text = "/uploads/" <> tableName <> "/" <> tshow (getField @"id" user) <> "/picture." <> ext
Expand Down

0 comments on commit 5211c0b

Please sign in to comment.