Commit f2d2cbf0 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[zip] base64-encoded zip file upload

parent 456fa548
......@@ -19,6 +19,7 @@ to generate this file without the comments in this block.
, "argonaut-codecs"
, "argonaut-core"
, "arrays"
, "b64"
, "bifunctors"
, "colors"
, "console"
......
......@@ -2,12 +2,13 @@ module Gargantext.Components.Forest.Tree.Node.Action.Upload where
import Gargantext.Prelude
import Data.Either (Either, fromRight')
import Data.Either (Either(..), fromRight')
import Data.Eq.Generic (genericEq)
import Data.Foldable (intercalate)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..), fromJust, fromMaybe, isNothing)
import Data.Newtype (class Newtype)
import Data.String.Base64 as B64
import Data.String.Regex as DSR
import Data.String.Regex.Flags as DSRF
import Data.Tuple (Tuple(..))
......@@ -193,7 +194,6 @@ uploadButtonCpt = here.component "uploadButton" cpt
let disabled = isNothing mFile' || onPending
pure $
H.div
{ className: "action-upload-button" }
[
......@@ -368,7 +368,12 @@ uploadFile { contents, fileType, id, nodeType, mName, session } = do
pure $ (\task -> GT.AsyncTaskWithType { task, typ }) <$> eTask
--postMultipartFormData session p fileContents
where
bodyParams = [ Tuple "_wf_data" (Just contents)
data' = case fileType of
ZIP -> case B64.btoa contents of
Left _err -> Nothing
Right dd -> Just dd
_ -> Just contents
bodyParams = [ Tuple "_wf_data" data'
, Tuple "_wf_filetype" (Just $ show fileType)
, Tuple "_wf_name" mName
]
......
......@@ -659,7 +659,6 @@ data AsyncTaskType = AddNode
| GraphRecompute
| ListUpload
| ListCSVUpload -- legacy v3 CSV upload for lists
| ListZIPUpload
| Query
| UpdateNgramsCharts
| UpdateNode
......@@ -680,7 +679,6 @@ asyncTaskTypePath CorpusFormUpload = "add/form/async/"
asyncTaskTypePath GraphRecompute = "async/recompute/"
asyncTaskTypePath ListUpload = "add/form/async/"
asyncTaskTypePath ListCSVUpload = "csv/add/form/async/"
asyncTaskTypePath ListZIPUpload = "zip/add/form/async/"
asyncTaskTypePath Query = "query/"
asyncTaskTypePath UpdateNgramsCharts = "ngrams/async/charts/update/"
asyncTaskTypePath UpdateNode = "update/"
......
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