BigBoy1337
BigBoy1337

Reputation: 4963

How can I put a file upload form into my Pyramid app?

I am going through of this tutorial, but it is very confusing to me. First of all, in the store_mp3_view function, both file and filename are referenced when declaring filename and input_file (first two lines). From the form above, it seems that only file is an input (filename is never mentioned). Is filename automatically input?

Additionally, is the loop at the end writing the data to the output file necessary? For my application, I want to the upload process to start a separate script that parses data from the file. Do I have to first put the data into an output file and then parse that or was that just for the example?

Upvotes: 1

Views: 731

Answers (1)

Brian Cajes
Brian Cajes

Reputation: 3402

From the form above it seems that only file is an input (filename is never mentioned). Is filename automatically input?

Correct, 'filename' attribute should be available anytime you upload a file from a form.

Do I have to first put the data into an output file and then parse that or was that just for the example?

input_data is a file object, but you do not need to write input_data out to disk before parsing it, this example just happens to be writing it to disk.

Upvotes: 1

Related Questions