Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>render_partial</em> isn't what you want.</p> <p>First, <a href="https://superuser.com/a/133253/34808">re-encode the executable in base64 format</a>, and specify that the template is base64 encoded (This is assuming hex is not a requirement for your app):</p> <pre><code>@@ template-name (base64) </code></pre> <p>Also, you don't actually need a controller method at all. Mojolicious will handle the process for you - all you have to do is appropriately name the template.</p> <pre><code>use Mojolicious::Lite; app-&gt;start; __DATA__ @@ Test.exe (base64) ... </code></pre> <p><a href="http://127.0.0.1:3000/Test.exe" rel="nofollow noreferrer">http://127.0.0.1:3000/Test.exe</a> will then download the file.</p> <p>-</p> <p>If you still want to use a controller method for app-specific concerns, get the data template specifically:</p> <pre><code>use Mojolicious::Lite; get '/download' =&gt; sub { my $self = shift; # http://mojolicio.us/perldoc/Mojolicious/Renderer.pm#get_data_template my $data = $self-&gt;app-&gt;renderer-&gt;get_data_template({}, 'Test.exe'); # Replace content-disposition instead of adding it, # to prevent duplication from elsewhere in the app $self-&gt;res-&gt;headers-&gt;header( 'Content-Disposition', 'attachment;filename=name.exe'); $self-&gt;render_data($data); }; app-&gt;start; __DATA__ @@ Test.exe (base64) ... </code></pre> <p><a href="http://127.0.0.1:3000/download" rel="nofollow noreferrer">http://127.0.0.1:3000/download</a> will get the template, set the header, and then download it as name.exe.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload