On 2006-03-28, Giannis Economou <suppressed> wrote:
>
> Giannis Economou wrote:
>> Hello all...
>>
>> Has anyone use CAP::ValidateRM validating file uploads, together with
>> CGI::Uploader successfully?
>>
>> Unfortunately I'm trying to make them work together but can't make it
>> right.
>> The problem is that the mime-type of the upload can not be determined
>> correctly by CGI::Upload.
>>
>> Some source:
>> my ($results, $err_page) =
>> $self->check_rm('reg_services','_services_profile');
>> if ($err_page) { $self->log->debug("Found validation errors in
>> submission"); return $err_page; }
>> my $valid = $results->valid;
>> my $u = CGI::Uploader->new( spec => { letter_file => {} },
>> updir_url =>
>> $self->get_app_config('BaseURL') .'/externals/',
>> updir_path => $uploads_path,
>> dbh => $self->dbh,
>> query => $self->query,
>> up_table => 'uploads',
>> );
>> my $valid_after_ul = $u->store_uploads( $valid );
>>
>>
>> and in the validation profile:
>> constraint_methods => {
>> letter_file => [
>> file_format( mime_types
>> => [ 'application/pdf','application/msword' ] ),
>> file_max_bytes(1024000),
>> ],
>> },
>>
> Update:
> When commenting the constraint as follows:
> constraint_methods => {
> letter_file => [
> #file_format( mime_types
>=> [ 'application/pdf','application/msword' ] ), #text/vnd.ms-word
> file_max_bytes(1024000),
> ],
> },
>
> CGI::Upload is able to determine the mime type fine. But with the line:
> file_format( mime_types => [ 'application/pdf','application/msword'
> ] ),
> not commented, CGI::Upload can not determine the MIME type and always
> inserts "application/octet-stream" with ".bin" extension in the database.
>
> It seems like a bug? If both CGI::Upload and
> Data::FormValidator::Constraints::Upload try to get the mime type,
> Data::FormValidator::Constraints::Upload (as the first one) does it
> successfully, but CGI::Upload fails afterwards.
Giannis,
Be careful: You are using 'CGI::Upload' and 'CGI::Uploader'
interchangeably, but they are different projects.
There is probably a true bug with File::MMagic not being able to guess
the file type correctly, and returning "application/octet-stream"
instead. (They both use it).
I suspect that the module that appears to "work" is not using
File::MMagic's value as the default, but CGI::Uploader is.
A number of times I've find File::MMagic to be unreliable, and should
probably get relying on it to return useful values.
If there's not already a bug to that effect for CGI::Uploader, please
file one. A patch would be welcome as well.
Mark
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.