Mojolicious::Lite daemon upload size limit?

638 views
Skip to first unread message

BlueT

unread,
Apr 8, 2010, 9:05:42 AM4/8/10
to mojol...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello gurus,

I'm making a new website, which can let users upload their photos.
I follow this example:
http://d.hatena.ne.jp/yukikimoto/20100212/1265989676

Everything goes well except I try to upload a pic which's size is bigger
than 512K.
Firefox says "The connection was reset" and the photo is only partial
uploaded when I check the page.

I noticed that all files which should be >512K, has only 512K (partial)
uploaded and saved into my disk.

I'm using perl 5.10.1, with Mojolicious 0.999924.


My question is:
1. Is there (and why is there) a 512K limitation of uploading size?
2. How could I tune the upload size limit to a bigger number?


Best wishes,
BlueT
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEUEARECAAYFAku91KYACgkQfoJ/q1KWx6g5YACfSGZUZHE/3Ne/E88ouB7O1DCF
eDYAmMrv3p5M24fD8V2wDzuqj6GrBEI=
=xRG4
-----END PGP SIGNATURE-----

Dotan Dimet

unread,
Apr 8, 2010, 9:12:25 AM4/8/10
to mojol...@googlegroups.com
Look at the code in the example you are using, specifically this part:

# Upload max size
my $upload_max_size =3 *1024 *1024;

# Over max size
if ($image->size> $upload_max_size) {
return $self->render(
template=> 'error',
message=> "Upload fail. Image size is too large."
);
}


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Анатолий Шарифулин

unread,
Apr 8, 2010, 9:15:27 AM4/8/10
to mojol...@googlegroups.com
script/app

BEGIN {
    $ENV{MOJO_MAX_MESSAGE_SIZE} = 2 * 1024 * 1024 * 1024; # 2 GB
};

If request is larger than limit, client'll see 413 error





--
To unsubscribe, reply using "remove me" as the subject.



--
С уважением,
Анатолий Шарифулин.

BlueT

unread,
Apr 8, 2010, 9:22:10 AM4/8/10
to mojol...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yes, I know that's a 3 MB limit.
But now I cannot even upload a file >512K.
(I was trying to upload files aroud 1~2M, not bigger than 3M :S)

iEYEARECAAYFAku92IIACgkQfoJ/q1KWx6h9LgCeJmRjUUhQbRILzQmWWvrFI4nj
p64An1RJjm7N0DZAhSvFzmSfNoJD0joT
=OR9d
-----END PGP SIGNATURE-----

Sebastian Riedel

unread,
Apr 8, 2010, 9:25:14 AM4/8/10
to mojol...@googlegroups.com
> BEGIN {
> $ENV{MOJO_MAX_MESSAGE_SIZE} = 2 * 1024 * 1024 * 1024; # 2 GB
> };

This.
Btw. You can capture uploads that were too big by checking $self->req->error for a 413 and then send a friendly error message back.

--
Sebastian Riedel
http://labs.kraih.com
http://mojolicious.org
http://twitter.com/kraih

Анатолий Шарифулин

unread,
Apr 8, 2010, 9:35:04 AM4/8/10
to mojol...@googlegroups.com
Btw. You can capture uploads that were too big by checking $self->req->error for a 413 and then send a friendly error message back.


Where can I use this checking? In action?
Can you show me example code?

 
--
To unsubscribe, reply using "remove me" as the subject.

Sebastian Riedel

unread,
Apr 8, 2010, 11:36:29 AM4/8/10
to mojol...@googlegroups.com
> Btw. You can capture uploads that were too big by checking $self->req->error for a 413 and then send a friendly error message back.
>
>
> Where can I use this checking? In action?
> Can you show me example code?

Yes, right in the action, it's basically just like a normal action call only the upload was interrupted.

http://github.com/kraih/mojo/blob/master/t/mojolicious/lite_app.t#L58

Sebastian Riedel

unread,
Apr 8, 2010, 11:38:09 AM4/8/10
to mojol...@googlegroups.com
> http://github.com/kraih/mojo/blob/master/t/mojolicious/lite_app.t#L58

Error handling like this is still a work in progress, so feedback would be appreciated, even if it just works for you. ;)

BlueT

unread,
Apr 8, 2010, 1:42:55 PM4/8/10
to mojol...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It works, thanx alot!

I wonder why I can't see this on the pod/documents, it's really useful
and many some kind of FAQ I think.
(or maybe it's already documented in some documents but I missed them?)

> --

> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.


> --
> To unsubscribe, reply using "remove me" as the subject.


> --
> С уважением,
> Анатолий Шарифулин.

-----BEGIN PGP SIGNATURE-----


Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAku+FZ4ACgkQfoJ/q1KWx6g3tACfVm34cbkDiNgwrp55epN4sLrI
cXwAoJEoI6krAFvWxdxDpShFPkMGadKz
=HpVd
-----END PGP SIGNATURE-----

Анатолий Шарифулин

unread,
Apr 8, 2010, 2:28:03 PM4/8/10
to mojol...@googlegroups.com

Анатолий Шарифулин

unread,
Apr 8, 2010, 2:29:10 PM4/8/10
to mojol...@googlegroups.com
Sebastian, good!

--
To unsubscribe, reply using "remove me" as the subject.
Reply all
Reply to author
Forward
0 new messages