App-MBUtiny
view release on metacpan or search on metacpan
lib/App/MBUtiny/Storage/HTTP.pm view on Meta::CPAN
my @array_ret = map {$_ = trim($_)} split /\s*\n+\s*/, $string_ret;
return wantarray ? @array_ret : $string_ret;
}
sub upload {
my $self = shift;
my %args = @_;
my $file = $args{file} || ''; # File for uploading! /path/to/file.tar.gz
my $name = $args{name} || basename($file); # File name! file.tar.gz
my $path = $args{path} ? sprintf("%s/%s", $args{path}, $name) : $name; # Path for request: /foo/bar
$self->request(PUT => $self->_merge_path_query($path), sub {
my $req = shift; # HTTP::Request object
$req->header('Content-Type', CONTENT_TYPE);
if (-e $file and -f $file) {
my $size = (-s $file) || 0;
return 0 unless $size;
#my $sizef = $size;
my $fh;
$req->content(sub {
unless ($fh) {
open($fh, "<", $file) or do {
$self->error(sprintf("Can't open file %s to read: %s", $file, $!));
( run in 0.254 second using v1.01-cache-2.11-cpan-de7293f3b23 )