Commit 11e9154c authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev-corpus-with-filetype' into dev

parents b50e7bde 9f9a8071
...@@ -398,10 +398,25 @@ getMetrics cId maybeListId tabType maybeLimit = do ...@@ -398,10 +398,25 @@ getMetrics cId maybeListId tabType maybeLimit = do
------------------------------------------------------------- -------------------------------------------------------------
type Hash = Text type Hash = Text
data FileType = CSV | PresseRIS
deriving (Eq, Show, Generic)
instance ToSchema FileType
instance Arbitrary FileType
where
arbitrary = elements [CSV, PresseRIS]
instance ToParamSchema FileType
instance ToParamSchema (MultipartData Mem) where instance ToParamSchema (MultipartData Mem) where
toParamSchema _ = toParamSchema (Proxy :: Proxy TODO) toParamSchema _ = toParamSchema (Proxy :: Proxy TODO)
instance FromHttpApiData FileType
where
parseUrlPiece "CSV" = pure CSV
parseUrlPiece "PresseRis" = pure PresseRIS
parseUrlPiece _ = pure CSV -- TODO error here
instance (ToParamSchema a, HasSwagger sub) => instance (ToParamSchema a, HasSwagger sub) =>
HasSwagger (MultipartForm tag a :> sub) where HasSwagger (MultipartForm tag a :> sub) where
-- TODO -- TODO
...@@ -417,10 +432,15 @@ instance (ToParamSchema a, HasSwagger sub) => ...@@ -417,10 +432,15 @@ instance (ToParamSchema a, HasSwagger sub) =>
type UploadAPI = Summary "Upload file(s) to a corpus" type UploadAPI = Summary "Upload file(s) to a corpus"
:> MultipartForm Mem (MultipartData Mem) :> MultipartForm Mem (MultipartData Mem)
:> QueryParam "fileType" FileType
:> Post '[JSON] [Hash] :> Post '[JSON] [Hash]
postUpload :: NodeId -> GargServer UploadAPI --postUpload :: NodeId -> Maybe FileType -> GargServer UploadAPI
postUpload _ multipartData = do --postUpload :: NodeId -> GargServer UploadAPI
postUpload :: NodeId -> MultipartData Mem -> Maybe FileType -> Cmd err [Hash]
postUpload _ _ Nothing = panic "fileType is a required parameter"
postUpload _ multipartData (Just fileType) = do
putStrLn $ "File Type: " <> (show fileType)
is <- liftIO $ do is <- liftIO $ do
putStrLn ("Inputs:" :: Text) putStrLn ("Inputs:" :: Text)
forM (inputs multipartData) $ \input -> do forM (inputs multipartData) $ \input -> do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment