I have an application to which multiple very large files
are PUT simultaneously, so I'd like to set the tmpdir used
by Mojo::Asset::File dynamically based on the request
headers. What's the best way to do this?
I tried an after_build_tx hook which modifies $tx
to use an object which inherits from Mojo::Message::Request
and has content which inherits from Mojo::Content::Single
and then sometimes sets MOJO_TMPDIR in parse() before
calling SUPER::parse(), but this doesn't seem like a
good solution. (Mostly since this technique stopped working in
recent releases for reasons that I haven't yet figured out.)
Maybe there's a simpler way to handle this with a callback
for the content, or "subscribing" to read events for the
incoming message/request/content?
thanks
Brian
Maybe there's a simpler way to handle this with a callbackfor the content, or "subscribing" to read events for theincoming message/request/content?
Thanks!
One minor change request (to be able to set tmpdir before adding a chunk) :
diff --git a/lib/Mojo/Asset/Memory.pm b/lib/Mojo/Asset/Memory.pm
index 864c755..29eff6d 100644
--- a/lib/Mojo/Asset/Memory.pm
+++ b/lib/Mojo/Asset/Memory.pm
@@ -20,8 +20,9 @@ sub add_chunk {
my ($self, $chunk) = @_;
$self->{content} .= $chunk if defined $chunk;
return $self unless $self->size > $self->max_memory_size;
- my $file = Mojo::Asset::File->new->add_chunk($self->slurp);
+ my $file = Mojo::Asset::File->new;
$self->emit(upgrade => $file);
+ $file->add_chunk($self->slurp);
return $file;
}
One minor change request (to be able to set tmpdir before adding a chunk) ...
Great, this works. Except sometimes it doesn't :
https://gist.github.com/1355027
https://gist.github.com/1355071
Brian
Looks like the latest changes in github fix
both of these.
Thanks a lot!
Brian