<commit_before>package Markers::ImageUpload::UploadService;
use Moose;

has 'file_store' => (
    'is' => 'ro',
    'isa' => 'FileStore::FileStoreService',
);

has 'markers_repository' => (
    'is' => 'ro',
    'isa' => 'Markers::MarkerRepository',
);

#########################################################################
# Usage      : @files_ids = save_uploads($uploads_aref);
# Purpose    : save uploads to file storage and get ids of files
# Returns    : none
# Parameters : $marker_id - id of a marker to add images to
#               $uplads_aref array reference for Wev::Request::Upload
# Throws     : no exceptions
# Comments   : ???
# See Also   : n/a
sub save_upload(){
    my ($self, $marker_id, $uploads_aref) = @_;

    my @uploaded_files_ids = _save_to_store($uploads_aref);
    $self->markers_repository->add_images_to_marker($marker_id, \@uploaded_files_ids);
}

sub _save_to_store(){
    my ($self, $uploads_aref) =@_;

    my @uploaded_files_ids = ();
    foreach my $tmp_file (@{$uploads_aref}){
        my $tmp_file_name = $tmp_file->tempname;
        if(-e $tmp_file_name){ #here will be proper validation
            my $file_id = $self->file_store->store_file($tmp_file_name);
            push @uploaded_files_ids, $file_id;
        }
    }

    return @uploaded_files_ids;<commit_msg>master Upload service returns url array for uploaded fies<commit_after>package Markers::ImageUpload::UploadService;
use Moose;

has 'file_store' => (
    'is' => 'ro',
    'isa' => 'FileStore::FileStoreService',
);

has 'markers_repository' => (
    'is' => 'ro',
    'isa' => 'Markers::MarkerRepository',
);

#########################################################################
# Usage      : @files_ids = save_uploads($uploads_aref);
# Purpose    : save uploads to file storage and get ids of files
# Returns    : urls array for uploaded files
# Parameters : $marker_id - id of a marker to add images to
#               $uplads_aref array reference for Wev::Request::Upload
# Throws     : no exceptions
# Comments   : ???
# See Also   : n/a
sub save_upload(){
    my ($self, $marker_id, $uploads_aref) = @_;

    my @uploaded_files_ids = _save_to_store($uploads_aref);
    $self->markers_repository->add_images_to_marker($marker_id, \@uploaded_files_ids);

    return $self->file_store->get_urls_for_ids(\@uploaded_files_ids);
}

sub _save_to_store(){
    my ($self, $uploads_aref) =@_;

    my @uploaded_files_ids = ();
    foreach my $tmp_file (@{$uploads_aref}){
        my $tmp_file_name = $tmp_file->tempname;
        if(-e $tmp_file_name){ #here will be proper validation
            my $file_id = $self->file_store->store_file($tmp_file_name);
            push @uploaded_files_ids, $file_id;
        }
    }

    return @uploaded_files_ids;
{'fraction_non_alphanumeric': 0.18208092485549132, 'fraction_numerical': 0.0, 'mean_word_length': 3.7823834196891193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1070185', 'n_tokens_mistral': 929, 'n_tokens_neox': 899, 'n_words': 201}