In my SAFE stack app, I need to send some Excel files from the Client to the Server.
My Fable.Remoting function signature is
UploadFiles: SecureInteraction<byte[], unit>
I am loading the files into client (which is made with Fulma) like this
Field.div [] [
File.file [] [
File.label [] [
File.input [
GenericOption.Props [
OnInput (fun ev ->
ev.target?files |> Seq.length |> ExpectFileCount |> dispatch
ev.target?files |> Seq.iter (fun file ->
let reader = Browser.Dom.FileReader.Create()
reader.onload <- fun evt ->
dispatch (SaveFileContent evt.target?result)
reader.onerror <- fun evt ->
dispatch ErrorReadingFile
reader.readAsText(file)
)
//let file = ev.target?files?(0)
)
Props.Multiple true
]
]
File.cta [] [
str "Choose a file..."
]
]
]
]
If I interpret the file contents as a string using System.Text.Encoding.UTF8.GetString
then I get it to display a bunch of nonsense, which makes me think the binary data is loaded into memory.
However, when I try to send it to the server it get the following Client error
TypeError: source$$1.map is not a function
The server never receives anything at all.
How do I use fable remoting to send binary data from the client to the server?
question from:
https://stackoverflow.com/questions/65862841/how-to-send-binary-data-from-local-disc-on-client-to-server-using-fable-remoting 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…