8
$\begingroup$

Bug introduced in 10.0 and fixed in 10.3 or earlier


I want to upload a file to the Wolfram Cloud and plot the list: So I use the following code to check its head at the beginning:

CloudDeploy[FormFunction[{"file" -> "XLS"},Head[#file]&], Permissions -> "Public"]

Output is:

CloudObject[ https://www.wolframcloud.com/objects/7d8de66e-be8b-496e-a692-124593ee3879 ]

But when I upload a XLS file and then submit,it can not continue,it throws a error:

upload a file of type XLS

enter image description here

If I check this file type on my computer:

FileFormat["F:\\learning_mma\\testfile.xls"]

result is:

XLS

So my question is how to upload a XLS file to the Clould and then plot it?

$\endgroup$
  • $\begingroup$ This is a related question and still unanswered by WRI. I did ask at the WTC conference last week, sent a mail to a main developer, but never heard back (maybe it went into a Spam folder? Or they are very very busy fixing things. Probably.) $\endgroup$ – Rolf Mertig Oct 31 '14 at 14:42
  • $\begingroup$ yes,simular this code:CloudDeploy[ FormFunction[{"image" -> "Image"}, EdgeDetect[#image] &, "JPEG"]] can run.and CloudDeploy[FormFunction[{"lis"->"List"},Length[#lis]&],Permissions->"Public"] also can run.But XLS can't be done. $\endgroup$ – partida Oct 31 '14 at 15:09
  • 1
    $\begingroup$ @Rolf Mertig I feedback to wolfram and get the answer.This is a known issue with using "UploadedFile" with FormFunction. I have updated the bug report with your case. Thank you very much for giving us feedback. Sincerely, Xin Xiao Wolfram Technical Support $\endgroup$ – partida Nov 11 '14 at 4:59
  • 1
    $\begingroup$ If anyone knows whether this bug has been fixed, please update the bug header (see meta.mathematica.stackexchange.com/questions/1610/…). $\endgroup$ – Michael E2 Aug 9 '15 at 12:03
  • 2
    $\begingroup$ @MichaelE2 It works now. Difficult to say which (cloud) version corrected the bug. Not really relevant though, since only the latest version (10.3 at the moment) is accessible. $\endgroup$ – Sjoerd C. de Vries Dec 6 '15 at 22:41
2
$\begingroup$

Suppose you create

Export["test.xls", RandomReal[1, 42]]

Then this seems to work in creating a nice plot (it will not look nice without specifying FontFamily, somehow, strangely).

CloudDeploy[
 FormFunction[{"file" -> "XLS"}, 
  ListLinePlot[Transpose[First[#file]], 
    LabelStyle -> {FontFamily -> "Tahoma", FontSize -> 16}] &], 
 Permissions -> "Public"]
$\endgroup$
8
$\begingroup$

So, let's hope this will be fixed in the next version. Until then this simple workaround, using "Binary" as an intermediate format, will do it:

  CloudDeploy@
         FormFunction[{"data" -> "Binary"}, 
                     (
                      CloudPut[#data, "excelFile"]; 
                      "Uploaded XLSX"
                     ) &
         ]

Then, after uploading an Excel file through the browser, you can get the content of the Excel file into Mathematica simply by:

Composition[ ImportString[#, "XLSX"] &,
             ExportString[#, "Binary"] &,
             CloudGet
] @ "excelFile"
$\endgroup$
2
$\begingroup$

If you're willing to use a text file instead of XLS, here's the code I use to upload & plot two columns from a text file:

CloudDeploy[FormFunction[
"x" -> "Text",
ListPlot[ImportString[#x, "Data"]] &, "PNG"
], Permissions -> "Public"]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.