1 |
3 |
ahitrov@rambler.ru |
<%args> |
2 |
|
|
|
3 |
|
|
$SETS => undef |
4 |
|
|
$field => undef |
5 |
|
|
$default => undef |
6 |
|
|
$object => undef |
7 |
|
|
$prop => undef |
8 |
|
|
$filen => undef |
9 |
|
|
|
10 |
|
|
</%args> |
11 |
|
|
|
12 |
|
|
<%init> |
13 |
|
|
|
14 |
|
|
use IO::File; |
15 |
|
|
use Contenido::Type::Audio; |
16 |
|
|
|
17 |
|
|
return undef unless defined $SETS and defined $field; |
18 |
|
|
|
19 |
|
|
# -------------------------------------------------------------------------------------- |
20 |
|
|
# ����� ���� �� ���� |
21 |
|
|
|
22 |
|
|
my $BINARY = $default; |
23 |
|
|
|
24 |
|
|
if ($SETS->{$field}) { |
25 |
|
|
my $filename = "/binary/".($object->get_file_name() || $filen) || return; |
26 |
|
|
|
27 |
|
|
if (ref $BINARY) {$BINARY->remove} |
28 |
|
|
|
29 |
|
|
my $upload = $r->upload($field); |
30 |
|
|
my $audio_file = new Contenido::Type::Audio; |
31 |
|
|
$audio_file->put_local($upload->filename(), $upload); |
32 |
|
|
$audio_file->store($filename.'.'.$audio_file->{'ext'}); |
33 |
|
|
$audio_file->clean; |
34 |
|
|
|
35 |
|
|
$BINARY = $audio_file; |
36 |
|
|
} |
37 |
|
|
|
38 |
|
|
|
39 |
|
|
return $BINARY; |
40 |
|
|
|
41 |
|
|
</%init> |