Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
57a52c51
Commit
57a52c51
authored
Jan 16, 2020
by
Przemyslaw Kaminski
Committed by
Alexandre Delanoë
Jan 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Tree] file upload: add full body Array Tuple to postWwwUrlencoded
parent
d89d4a64
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
7 deletions
+13
-7
Upload.purs
...Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
+7
-3
REST.purs
src/Gargantext/Config/REST.purs
+5
-3
Sessions.purs
src/Gargantext/Sessions.purs
+1
-1
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
View file @
57a52c51
...
...
@@ -3,7 +3,7 @@ module Gargantext.Components.Forest.Tree.Node.Action.Upload where
import Prelude (class Show, Unit, const, discard, map, pure, show, ($), (<>), bind, void)
import Data.Maybe (Maybe(..), fromJust)
import Data.Newtype (class Newtype)
import Data.Tuple (Tuple)
import Data.Tuple (Tuple
(..)
)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect)
...
...
@@ -169,8 +169,12 @@ instance fileUploadQueryToQuery :: ToQuery FileUploadQuery where
uploadFile :: Session -> ID -> FileType -> UploadFileContents -> Aff AsyncTask
uploadFile session id fileType (UploadFileContents fileContents) =
postWwwUrlencoded session p
fileContent
s
postWwwUrlencoded session p
bodyParam
s
--postMultipartFormData session p fileContents
where
q = FileUploadQuery { fileType: fileType }
p = NodeAPI Corpus (Just id) $ "add/form/async" <> Q.print (toQuery q)
p = NodeAPI Corpus (Just id) $ "add/file/async" <> Q.print (toQuery q)
bodyParams = [
Tuple "_wf_data" (Just fileContents)
, Tuple "_wf_filetype" (Just $ show fileType)
]
src/Gargantext/Config/REST.purs
View file @
57a52c51
...
...
@@ -69,9 +69,11 @@ deleteWithBody mtoken url = send DELETE mtoken url <<< Just
post :: forall a b. EncodeJson a => DecodeJson b => Maybe Token -> String -> a -> Aff b
post mtoken url = send POST mtoken url <<< Just
type FormDataParams = Array (Tuple String (Maybe String))
-- TODO too much duplicate code with `send`
postWwwUrlencoded :: forall b. DecodeJson b => Maybe Token -> String ->
String
-> Aff b
postWwwUrlencoded mtoken url body = do
postWwwUrlencoded :: forall b. DecodeJson b => Maybe Token -> String ->
FormDataParams
-> Aff b
postWwwUrlencoded mtoken url body
Params
= do
affResp <- request $ defaultRequest
{ url = url
, responseFormat = ResponseFormat.json
...
...
@@ -96,7 +98,7 @@ postWwwUrlencoded mtoken url body = do
Left err -> throwError $ error $ "decodeJson affResp.body: " <> err
Right b -> pure b
where
urlEncodedBody = FormURLEncoded.fromArray
[Tuple "body" (Just body)]
urlEncodedBody = FormURLEncoded.fromArray
bodyParams
postMultipartFormData :: forall b. DecodeJson b => Maybe Token -> String -> String -> Aff b
postMultipartFormData mtoken url body = do
...
...
src/Gargantext/Sessions.purs
View file @
57a52c51
...
...
@@ -223,7 +223,7 @@ deleteWithBody session@(Session {token}) p = REST.deleteWithBody (Just token) (t
post :: forall a b p. EncodeJson a => DecodeJson b => ToUrl Session p => Session -> p -> a -> Aff b
post session@(Session {token}) p = REST.post (Just token) (toUrl session p)
postWwwUrlencoded :: forall b p. DecodeJson b => ToUrl Session p => Session -> p ->
String
-> Aff b
postWwwUrlencoded :: forall b p. DecodeJson b => ToUrl Session p => Session -> p ->
REST.FormDataParams
-> Aff b
postWwwUrlencoded session@(Session {token}) p = REST.postWwwUrlencoded (Just token) (toUrl session p)
postMultipartFormData :: forall b p. DecodeJson b => ToUrl Session p => Session -> p -> String -> Aff b
...
...
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