Now you can have a subpath under the S3 bucket
parent
ab0a939550
commit
d1ac88d301
|
@ -428,8 +428,8 @@ sub delete_files {
|
||||||
if ( $$Storage{Type} and ( $$Storage{Type} eq 's3fs' ) ) {
|
if ( $$Storage{Type} and ( $$Storage{Type} eq 's3fs' ) ) {
|
||||||
my $url = $$Storage{Url};
|
my $url = $$Storage{Url};
|
||||||
$url =~ s/^(s3|s3fs):\/\///ig;
|
$url =~ s/^(s3|s3fs):\/\///ig;
|
||||||
my ( $aws_id, $aws_secret, $aws_host, $aws_bucket ) = ( $url =~ /^\s*([^:]+):([^@]+)@([^\/]*)\/(.+)\s*$/ );
|
my ( $aws_id, $aws_secret, $aws_host, $aws_bucket, $subpath ) = ( $url =~ /^\s*([^:]+):([^@]+)@([^\/]*)\/([^\/]+)(\/.+)?\s*$/ );
|
||||||
Debug("S3 url parsed to id:$aws_id secret:$aws_secret host:$aws_host, bucket:$aws_bucket");
|
Debug("S3 url parsed to id:$aws_id secret:$aws_secret host:$aws_host, bucket:$aws_bucket, subpath:$subpath\n from $url");
|
||||||
eval {
|
eval {
|
||||||
require Net::Amazon::S3;
|
require Net::Amazon::S3;
|
||||||
my $s3 = Net::Amazon::S3->new( {
|
my $s3 = Net::Amazon::S3->new( {
|
||||||
|
@ -443,7 +443,7 @@ sub delete_files {
|
||||||
Error("S3 bucket $bucket not found.");
|
Error("S3 bucket $bucket not found.");
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
if ( $bucket->delete_key($event_path) ) {
|
if ( $bucket->delete_key($subpath.$event_path) ) {
|
||||||
$deleted = 1;
|
$deleted = 1;
|
||||||
} else {
|
} else {
|
||||||
Error('Failed to delete from S3:'.$s3->err . ': ' . $s3->errstr);
|
Error('Failed to delete from S3:'.$s3->err . ': ' . $s3->errstr);
|
||||||
|
@ -554,8 +554,10 @@ sub CopyTo {
|
||||||
return 'Event is already located at ' . $NewPath;
|
return 'Event is already located at ' . $NewPath;
|
||||||
} elsif ( !$NewPath ) {
|
} elsif ( !$NewPath ) {
|
||||||
return "New path ($NewPath) is empty.";
|
return "New path ($NewPath) is empty.";
|
||||||
} elsif ( ! -e $NewPath ) {
|
} elsif ( ($$NewStorage{Type} ne 's3fs' ) and ! -e $NewPath ) {
|
||||||
|
if ( ! mkdir($NewPath) ) {
|
||||||
return "New path $NewPath does not exist.";
|
return "New path $NewPath does not exist.";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Debug("$NewPath is good");
|
Debug("$NewPath is good");
|
||||||
}
|
}
|
||||||
|
@ -588,8 +590,8 @@ sub CopyTo {
|
||||||
if ( $$NewStorage{Url} ) {
|
if ( $$NewStorage{Url} ) {
|
||||||
my $url = $$NewStorage{Url};
|
my $url = $$NewStorage{Url};
|
||||||
$url =~ s/^(s3|s3fs):\/\///ig;
|
$url =~ s/^(s3|s3fs):\/\///ig;
|
||||||
my ( $aws_id, $aws_secret, $aws_host, $aws_bucket ) = ( $url =~ /^\s*([^:]+):([^@]+)@([^\/]*)\/(.+)\s*$/ );
|
my ( $aws_id, $aws_secret, $aws_host, $aws_bucket, $subpath ) = ( $url =~ /^\s*([^:]+):([^@]+)@([^\/]*)\/([^\/]+)(\/.+)?\s*$/ );
|
||||||
Debug("S3 url parsed to id:$aws_id secret:$aws_secret host:$aws_host, bucket:$aws_bucket");
|
Debug("S3 url parsed to id:$aws_id secret:$aws_secret host:$aws_host, bucket:$aws_bucket, subpath:$subpath\n from $url");
|
||||||
if ( $aws_id and $aws_secret and $aws_host and $aws_bucket ) {
|
if ( $aws_id and $aws_secret and $aws_host and $aws_bucket ) {
|
||||||
eval {
|
eval {
|
||||||
require Net::Amazon::S3;
|
require Net::Amazon::S3;
|
||||||
|
@ -606,7 +608,7 @@ sub CopyTo {
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $event_path = $self->RelativePath();
|
my $event_path = $subpath.$self->RelativePath();
|
||||||
if ( 0 ) { # Not neccessary
|
if ( 0 ) { # Not neccessary
|
||||||
Debug("Making directory $event_path/");
|
Debug("Making directory $event_path/");
|
||||||
if ( !$bucket->add_key($event_path.'/', '') ) {
|
if ( !$bucket->add_key($event_path.'/', '') ) {
|
||||||
|
|
Loading…
Reference in New Issue