Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
145
Issues
145
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
45b48498
Commit
45b48498
authored
May 14, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Missing file
parent
78e599d1
Pipeline
#385
failed with stage
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
Upload.hs
src/Gargantext/API/Upload.hs
+71
-0
No files found.
src/Gargantext/API/Upload.hs
0 → 100644
View file @
45b48498
{-|
Module : Gargantext.API.Upload
Description : Server API
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
module
Gargantext.API.Upload
where
import
Gargantext.Prelude
import
Data.Text
(
Text
)
import
Servant
import
Servant.Multipart
import
qualified
Data.ByteString.Lazy
as
LBS
import
Control.Monad
import
Control.Monad.IO.Class
import
Gargantext.API.Types
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
Data.Swagger
-- | Upload files
-- TODO Is it possible to adapt the function according to iValue input ?
--type API = MultipartForm Mem (MultipartData Mem) :> Post '[JSON] Integer
instance
Generic
Mem
instance
ToSchema
Mem
instance
Arbitrary
Mem
instance
ToSchema
(
MultipartData
Mem
)
instance
Arbitrary
(
MultipartData
Mem
)
instance
ToSchema
(
MultipartForm
Mem
(
MultipartData
Mem
))
instance
Arbitrary
(
MultipartForm
Mem
(
MultipartData
Mem
))
type
ApiUpload
=
MultipartForm
Mem
(
MultipartData
Mem
)
:>
Post
'[
J
SON
]
Integer
-- MultipartData consists in textual inputs,
-- accessible through its "inputs" field, as well
-- as files, accessible through its "files" field.
upload
::
GargServer
ApiUpload
upload
multipartData
=
do
liftIO
$
do
putStrLn
(
"Inputs:"
::
Text
)
forM_
(
inputs
multipartData
)
$
\
input
->
putStrLn
$
(
" "
::
Text
)
<>
(
iName
input
)
<>
(
" -> "
::
Text
)
<>
(
iValue
input
)
forM_
(
files
multipartData
)
$
\
file
->
do
let
content
=
fdPayload
file
putStrLn
$
(
"Content of "
::
Text
)
<>
(
fdFileName
file
)
LBS
.
putStr
content
return
0
-------------------------------------------------------------------------------
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment