Commit 36b1f7eb authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[upload] implement simple endpoint for zip file upload

parent 35c457c6
Pipeline #1934 passed with stage
in 49 minutes and 52 seconds
......@@ -257,6 +257,7 @@ addToCorpusWithForm user cid (NewWithForm ft d l _n) logStatus jobLog = do
CSV -> Parser.parseFormat Parser.CsvGargV3
WOS -> Parser.parseFormat Parser.WOS
PresseRIS -> Parser.parseFormat Parser.RisPresse
ZIP -> Parser.parseFormat Parser.ZIP
-- TODO granularity of the logStatus
eDocs <- liftBase $ parse $ cs d
......@@ -370,3 +371,4 @@ addToCorpusWithFile user cid nwf@(NewWithFile _d _l fName) logStatus = do
, _scst_remaining = Just 0
, _scst_events = Just []
}
......@@ -45,25 +45,24 @@ data FileType = CSV
| CSV_HAL
| PresseRIS
| WOS
| ZIP
deriving (Eq, Show, Generic)
instance ToSchema FileType
instance Arbitrary FileType
where
arbitrary = elements [CSV, PresseRIS]
instance Arbitrary FileType where arbitrary = elements [CSV, PresseRIS]
instance ToParamSchema FileType
instance FromJSON FileType
instance ToJSON FileType
instance ToParamSchema (MultipartData Mem) where
toParamSchema _ = toParamSchema (Proxy :: Proxy TODO)
instance ToParamSchema (MultipartData Mem) where toParamSchema _ = toParamSchema (Proxy :: Proxy TODO)
instance FromHttpApiData FileType
where
parseUrlPiece "CSV" = pure CSV
parseUrlPiece "CSV_HAL" = pure CSV_HAL
parseUrlPiece "PresseRis" = pure PresseRIS
parseUrlPiece "ZIP" = pure ZIP
parseUrlPiece _ = pure CSV -- TODO error here
......
......@@ -68,6 +68,7 @@ type ParseError = String
-- different parser are available.
data FileFormat = WOS | RIS | RisPresse
| CsvGargV3 | CsvHal
| ZIP
deriving (Show)
-- Implemented (ISI Format)
......@@ -94,6 +95,9 @@ parseFormat WOS bs = do
$ partitionEithers
$ [runParser' WOS bs]
pure $ Right docs
parseFormat ZIP _bs = do
printDebug "[parseFormat]" ZIP
pure $ Left "Not implemented for ZIP"
parseFormat _ _ = undefined
-- | Parse file into documents
......
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