Skip to content

Commit

Permalink
docs(Uploader): Backend example with Perl/Mojolicious (#15106)
Browse files Browse the repository at this point in the history
* Backend example with Perl/Mojolicious

Just adding a simple example of uploader backend with Perl/Mojolicious.

* Update uploader.md

Co-authored-by: Razvan Stoenescu <razvan.stoenescu@gmail.com>
  • Loading branch information
mpserafim and rstoenescu committed Dec 16, 2022
1 parent 3fea6ce commit 7cd13d2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/src/pages/vue-components/uploader.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,37 @@ end
isrunning(:webserver) || up()
```

### Perl/Mojolicious

```
# Perl
use Mojolicious::Lite -signatures;
# CORS
app->hook(after_dispatch => sub {
my $c = shift;
$c->res->headers->header('Access-Control-Allow-Origin' => '*');
});
options '*' => sub ($c) {
$c->res->headers->header('Access-Control-Allow-Methods' => 'GET, OPTIONS, POST, DELETE, PUT');
$c->res->headers->header('Access-Control-Allow-Headers' => 'Content-Type');
$c->render(text => '');
};
post '/upload' => sub ($c) {
my $uploads = $c->req->uploads('files');
foreach my $f (@{$uploads}) {
$f->move_to('/tmp/' . $f->filename);
}
$c->render(text => 'Saved!');
};
app->start;
```

## Supporting other services
QUploader currently supports uploading through the HTTP(S) protocol. But you can extend the component to support other services as well. Like Firebase for example. Here's how you can do it.

Expand Down

0 comments on commit 7cd13d2

Please sign in to comment.