Using PSGI, is it possible to change the name of downloaded files?

I have a small PSGI application that takes a load from a form and passes it to another script for processing:

#!/usr/bin/perl use strict; use warnings; use Plack::Request; use HTTPStatusCode; my $app = sub { my $req = Plack::Request->new(shift); my $content; if (keys %{$req->uploads}) { $content = do_something_with_upload($req); } else { $content = display_form(); } return [ HTTPStatusCode->SUCCESS, [ 'Content-type', 'text/html' ], [ $content ], ]; }; 

The file loads successfully as something like /tmp/Fw8n6j0ICn.txt . The problem is that the processing depends on the file name, as it was at boot.

Is it possible to change the loading of files so that they go to /tmp/Fw8n6j0ICn/original_name.txt ?

+4
source share
1 answer

You can get the original file name using the filename method of the $request object, so that you can basically copy $request->path at any time convenient for you and process this file.

+4
source

Source: https://habr.com/ru/post/1436962/


All Articles