Message Boards Message Boards

FormFunction and CloudSave CloudObject

Posted 3 years ago

I would like to write something like

form = FormFunction["PartsLists" -> "CSV", 
  CloudSave[#PartsLists, CloudObject["MyProject/"]] &, "CSV", 
  AppearanceRules -> "Title" -> "Upload your Parts List here"]
CloudDeploy[form]

So that the user can submit the CSV file and save it in a cloud location, later on I would like to use that data with

Get[CloudObject["MyProject/"]]

It seems to work fine if I do it like this

test = Import["/Users/20 parts test.csv"];
CloudSave[test, CloudObject["MyProject/"]]

but I can't make it work in the FormFunction, any help pleeeeaase

POSTED BY: Rodrigo Amor
2 Replies
Posted 3 years ago

Thank you very much Joel, it took me a while to get everything running but it seems that it is working now. I apologize for my "I can't make it work", I don't know why I was cycled in the same mistake over and over and I was frustrated. Your advice was helpful and I am back in track again.

Thank you very much again. Regards,

Rodrigo

POSTED BY: Rodrigo Amor
Posted 3 years ago

First, just a word of advice: never say "I can't make it work" and leave it at that. Always use a "here's what I expected to happen, and here's what happened instead" pattern, with specifics.

Try changing CloudSave (which works like Save and expects to write the contents of a symbol, not a general expression) to CloudPut (which works like Put and expects to write an expression).

Also, pay attention to what the form function returns. Right now I see the browser downloading a file with the CloudObject expression in it, which is what CloudSave returned. Instead you could make a compound expression and return a message:

FormFunction[
    "PartsLists" -> "CSV",
    (
        CloudPut[#PartsLists, CloudObject["MyProject/"]];
        "Thank you!"
    )
 ]
POSTED BY: Joel Klein
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract