Backblaze-B2V4
view release on metacpan or search on metacpan
Retrieves a file plus metadata given the GUID of that file.
The 'file\_id' argument is required and will be the file's GUID.
If you would like to auto-save the file, provide a path to an
existing directory via the 'save\_to\_location' argument.
On success, will return the $response hashref with these keys:
file_contents
content-length
content-type
x-bz-file-id
x-bz-file-name
x-bz-content-sha1
See https://www.backblaze.com/b2/docs/b2\_download\_file\_by\_id.html
## b2\_download\_file\_by\_name
Works like b2\_download\_file\_by\_id() except that it expects 'bucket\_name'
and 'file\_name' named arguments arguments.
lib/Backblaze/B2V4.pm view on Meta::CPAN
# otherwise, we are attempting a GET
} else {
eval {
$response = HTTP::Tiny->new->get($api_url, {
'headers' => $headers,
});
# did we download a file?
if ($response->{headers}->{'x-bz-file-name'}) {
# grab those needed headers
foreach my $header ('content-length', 'content-type', 'x-bz-file-id', 'x-bz-file-name', 'x-bz-content-sha1') {
$b2_response->{$header} = $response->{headers}->{$header};
}
# and the file itself
$b2_response->{file_contents} = $response->{content};
} elsif ($response->{status} == 200) { # regular JSON, decode results
$b2_response = decode_json( $response->{content} );
}
};
lib/Backblaze/B2V4.pm view on Meta::CPAN
}
# must be 100MB or bigger
my $stat = path($args->file_location)->stat;
if ($stat->size < $self->api_info->{recommended_part_size} ) {
return $self->error_tracker(
'error_message' => 'Please use b2_upload_large_file() for files larger than ' . $self->api_info->{recommended_part_size},
);
}
# default content-type
$args->content_type ||= 'b2/x-auto';
my $bucket_id = $self->b2_get_bucket_id($args->bucket_name);
if (!$bucket_id) {
return $self->error_tracker(
'error_message' => 'Can not upload to ' . $args->bucket_name . ' because bucket not found.',
);
}
# kick off the upload in the API
lib/Backblaze/B2V4.pm view on Meta::CPAN
Retrieves a file plus metadata given the GUID of that file.
The 'file_id' argument is required and will be the file's GUID.
If you would like to auto-save the file, provide a path to an
existing directory via the 'save_to_location' argument.
On success, will return the $response hashref with these keys:
file_contents
content-length
content-type
x-bz-file-id
x-bz-file-name
x-bz-content-sha1
See https://www.backblaze.com/b2/docs/b2_download_file_by_id.html
=head2 b2_download_file_by_name
Works like b2_download_file_by_id() except that it expects 'bucket_name'
and 'file_name' named arguments arguments.
( run in 3.073 seconds using v1.01-cache-2.11-cpan-524268b4103 )