I have a test file(test1.txt
) in my desktop.This is its content.
FilePrint[FileNameJoin[{$HomeDirectory, "Desktop", "test1.txt"}]]
(*
31.16 220.49774362741593
31.18 223.49849688143496
31.2 226.49924900492292
31.22 223.5
31.24 228.5
31.26 231.5
31.28 227.5
31.3 222.5
31.32 222.5
35.72 209.72984917230133
35.74 220.68588083509488
*)
I try to use Import
and Export
in CloudDeploy
.
CloudDeploy[
FormPage["fileAddress" ->
"String", (data = Import[#fileAddress, "Table"]; Sin[data];
Export[FileNameJoin[{$HomeDirectory, "Desktop", "test.txt"}],
data]) &], Permissions -> "Public"]
Of course this action will get a error.But I have to say this two function can help a lot in real life.So any method or workaround can do this?
Aim:
I want to create some CloudObject
which have some specific function to help my friends who have no mma
.I hope she upload test1.txt
,then get test.txt
in her local disk.Just by her browser.
Answer
I do not think you can automatically save to someone's file system but you can create a download link, it is up to the user to click and get it:
CloudDeploy[
FormFunction[
{"first" -> "Number", "second" -> "Number"},
Module[{f = CreateFile[]},
StringTemplate[
"Click here to save test.txt"
][
URLShorten @@ CloudExport[#second + #first, "Text", "test.txt",
Permissions -> "Public"]
]
] &
],
Permissions -> "Public"
]
This is an example with two numbers input but you can easily use user6014's suggestion for files uploading
{"data" -> "CSV"}
and process them however you want.
Comments
Post a Comment