Xavier Robin wrote:
Hello,
I want to save uploaded files in a directory specific for the user (using the
user_id). For example, the files of user 326 would be saved in
directory /root/files/3/2/6/.
I use Catalyst::Model::File to do this. It's really great!
I configured it to store files in /root/files/ by default (root_dir). Now I
use the following code for a specific file:
my @path = split('', $c->user->user_id);
my $file_obj = $c->model('File')->file(@path , $filename);
But the file "test.txt" for user "326" is saved as /root/files/3 instead
of /root/files/3/2/6/test.txt.
It looks like C::M::File uses only the first argument and ignores all the
others, unlike Path::Class::File that allows to define the path with a list
of arguments.
I could fix the problem by using the following code where I pass a single
argument with the complete path:
my @path = split('', $c->user->user_id);
my $path = join ('/', @path);
my $file_obj = $c->model('File')->file($path . '/' . $filename);
But I find the Path::Class::File syntax looks much smarter and more
platform-independant. Is there an different syntax for C::M::File?
Thanks for this great framework !
Xavier
Nope - I just forgot to do that. If you could make a patch containing a
failing test I'll go ahead and implement that.
Cheers
Ash
_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/