<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Dear all,<br>
<br>
I am quite new to Dancer but I am really amazed on how few lines of
code I have to write for the same functionality (still exploring
though).<br>
<br>
However, I have hit the following issue: I am trying to upload a
file using the following code:<br>
<br>
<tt>put '/upload/:file' => sub {</tt><tt><br>
</tt><tt> my $upload_dir = "MyApp/UPLOADS";</tt><tt><br>
</tt><tt> my $filename = params->{file};</tt><tt><br>
</tt><tt> my $uploadedFile = request->upload($filename);</tt><tt><br>
</tt><tt><br>
</tt><tt> debug "My Log 1: " . params->{file};</tt><tt><br>
</tt><tt> debug "My Log 2: " . ref($uploadedFile);</tt><tt><br>
</tt><tt><br>
</tt><tt> open ( UPLOADFILE, "$upload_dir/$filename" ) or die
"$!";</tt><tt><br>
</tt><tt><br>
</tt><tt> while ( <UPLOADFILE> )</tt><tt><br>
</tt><tt> {</tt><tt><br>
</tt><tt> print UPLOADFILE;</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt><br>
</tt><tt> close UPLOADFILE;</tt><tt><br>
</tt><tt><br>
</tt><tt> return "DONE";</tt><tt><br>
</tt><tt>};</tt><br>
<br>
The PUT command is done via cURL as follows:<br>
<br>
<tt>curl --upload-file test <a class="moz-txt-link-freetext" href="http://localhost:3000/upload/test">http://localhost:3000/upload/test</a></tt><tt><br>
</tt><tt>DONE</tt><br>
<br>
The output that I see in the "development dance floor" is the
following:<br>
<br>
<tt>[9072] core @0.000341> request: PUT /upload/test from
127.0.0.1 in /Perl/site/lib/Dancer/Handler.pm l. 56</tt><tt><br>
</tt><tt>[9072] core @0.002434> [hit #1]Trying to match 'PUT
/upload/test' against /^\/upload\/([^\/]+)$/ (generated from
'/upload/:file') in /Perl/site/lib/Dancer/Route.pm l. 84</tt><tt><br>
</tt><tt>[9072] core @0.004173> [hit #1] --> got 1 in
/Perl/site/lib/Dancer/Route.pm l. 102</tt><tt><br>
</tt><tt>[9072] core @0.006625> [hit #1] --> named tokens
are: file in /Perl/site/lib/Dancer/Route.pm l. 130</tt><tt><br>
</tt><tt>[9072] debug @0.009443> [hit #1]My Log 1: test in
MyApp\lib/MyApp.pm l. 20</tt><tt><br>
</tt><tt>[9072] debug @0.010818> [hit #1]<b>My Log 2: in
MyApp\lib/MyApp.pm l. 21</b></tt><tt><br>
</tt><tt>[9072] core @0.015854> [hit #1]response: 200 in
/Perl/site/lib/Dancer/Handler.pm l. 179</tt><br>
<br>
The problem is that the file is created with the correct name in the
correct folder (MyApp/UPLOADS/test) but it is always empty (0 size).
No other warnings or errors, but I do see an issue in the output
(marked in bold - 2nd custom debug line). Any ideas?<br>
<br>
Thank you in advance for your time!<br>
<br>
Regards,<br>
<br>
Fotis<br>
<pre class="moz-signature" cols="72">--
Fotis E. Psomopoulos
PhD, Software Engineer
Intelligent Systems and Software Engineering Lab
Department of Electrical and Computer Engineering
Aristotle University of Thessaloniki
Thessaloniki 54124, Greece
Phone: +30 2310 99 6349
Fax : +30 2310 99 6398
Email: <a class="moz-txt-link-abbreviated" href="mailto:fpsom@issel.ee.auth.gr">fpsom@issel.ee.auth.gr</a>
Site : <a class="moz-txt-link-freetext" href="http://fotis.ee.auth.gr">http://fotis.ee.auth.gr</a></pre>
</body>
</html>