Change proof storage to have a settable folder
This commit is contained in:
parent
8c424c02d3
commit
4c5f27976c
8 changed files with 56 additions and 183 deletions
|
@ -62,12 +62,9 @@ sub post_upload {
|
|||
return $c->api_validation_error if $validation->has_error;
|
||||
|
||||
my $transaction_value = $validation->param('transaction_value');
|
||||
my $upload = $validation->param('file');
|
||||
|
||||
my $file = $validation->param('file');
|
||||
|
||||
my $ext = '.jpg';
|
||||
my $uuid = Data::UUID->new->create_str;
|
||||
my $filename = $uuid . $ext;
|
||||
my $file = $c->store_file_from_upload( $upload );
|
||||
|
||||
if ( $type == 1 ) {
|
||||
# Validated organisation
|
||||
|
@ -75,22 +72,18 @@ sub post_upload {
|
|||
buyeruserid_fk => $user->id,
|
||||
sellerorganisationid_fk => $validation->param('organisation_id'),
|
||||
valuemicrocurrency => $transaction_value,
|
||||
proofimage => $filename,
|
||||
proof_image => $file,
|
||||
timedatesubmitted => DateTime->now,
|
||||
});
|
||||
|
||||
$file->move_to('images/' . $filename);
|
||||
} elsif ( $type == 2 ) {
|
||||
# Unvalidated Organisation
|
||||
$c->schema->resultset('PendingTransaction')->create({
|
||||
buyeruserid_fk => $user->id,
|
||||
pendingsellerorganisationid_fk => $validation->param('organisation_id'),
|
||||
valuemicrocurrency => $transaction_value,
|
||||
proofimage => $filename,
|
||||
proof_image => $file,
|
||||
timedatesubmitted => DateTime->now,
|
||||
});
|
||||
|
||||
$file->move_to('images/' . $filename);
|
||||
} elsif ( $type == 3 ) {
|
||||
my $organisation_name = $validation->param('organisation_name');
|
||||
my $street_name = $validation->param('street_name');
|
||||
|
@ -110,11 +103,9 @@ sub post_upload {
|
|||
buyeruserid_fk => $user->id,
|
||||
pendingsellerorganisationid_fk => $pending_org->id,
|
||||
valuemicrocurrency => $transaction_value,
|
||||
proofimage => $filename,
|
||||
proof_image => $file,
|
||||
timedatesubmitted => DateTime->now,
|
||||
});
|
||||
|
||||
$file->move_to('images/' . $filename);
|
||||
}
|
||||
return $c->render( json => {
|
||||
success => Mojo::JSON->true,
|
||||
|
|
Reference in a new issue