Amazon-S3

 view release on metacpan or  search on metacpan

t/05-multipart-upload.t  view on Meta::CPAN

#!/usr/bin/perl -w

## no critic

use warnings;
use strict;

use lib qw( . lib);

use Carp;

use Data::Dumper;
use Digest::MD5::File qw(file_md5_hex);
use English           qw{-no_match_vars};
use File::Temp        qw{ tempfile };
use Test::More;

use S3TestUtils qw(:constants :subs);

my $host = set_s3_host();

if ( !$ENV{'AMAZON_S3_EXPENSIVE_TESTS'} ) {
  plan skip_all => 'Testing this module for real costs money.';
}
else {
  plan tests => 7;
}

use_ok('Amazon::S3');
use_ok('Amazon::S3::Bucket');

my $s3 = get_s3_service($host);

if ( !$s3 ) {
  BAIL_OUT('could not initialize s3 object');
}

my $bucket_name = make_bucket_name();
my $bucket_obj  = create_bucket( $s3, $bucket_name );

ok( ref $bucket_obj, 'created bucket - ' . $bucket_name );

if ( $EVAL_ERROR || !$bucket_obj ) {
  BAIL_OUT( $s3->err . ": " . $s3->errstr );
} ## end if ( $EVAL_ERROR || !$bucket_obj)

########################################################################
subtest 'multipart-manual' => sub {
########################################################################
  my $key = 'big-object-1';

  my $id = $bucket_obj->initiate_multipart_upload($key);

  my $part_list = {};

  my $part = 0;
  my $data = 'x' x ( 1024 * 1024 * 5 ); # 5 MB part

  my $etag
    = $bucket_obj->upload_part_of_multipart_upload( $key, $id, ++$part, $data,
    length $data );

  $part_list->{$part} = $etag;

  $bucket_obj->complete_multipart_upload( $key, $id, $part_list );

  my $head = $bucket_obj->head_key($key);



( run in 1.893 second using v1.01-cache-2.11-cpan-437f7b0c052 )