AWSの説明ページ

https://docs.aws.amazon.com/ja_jp/AmazonS3/latest/dev/mpuoverview.html

 

最少パートサイズ 5MB

https://docs.aws.amazon.com/ja_jp/AmazonS3/latest/dev/qfacts.html

 

AWS-SDKで試してみたが、やっぱり駄目みたい。

AWS HTTP error: Client error: 400 EntityTooSmall (client): Your proposed upload is smaller than the minimum allowed size –
<Error>
<Code>EntityTooSmall</Code>
<Message>Your proposed upload is smaller than the minimum allowed size</Message>
<ProposedSize>4194304</ProposedSize>
<MinSizeAllowed>5242880</MinSizeAllowed>
<PartNumber>1</PartNumber>
<ETag>xxx</ETag>
<RequestId>xxx</RequestId>
<HostId>xxx=</HostId>
</Error>’

 

PHP + CURLは、MultipartUploadがなぜだかそもそもうまくいってない。

<?xml version=”1.0″ encoding=”UTF-8″?>
<Error>
<Code>RequestTimeout</Code>
<Message>Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.</Message>
<RequestId>xxx</RequestId>
<HostId>xxx</HostId>
</Error>

 

★アップロード順番は順不同でも、completeMultipartUploadに渡す順序を正しく渡せばOK

$parts = array();

$partNumber = 2;
$file = fopen(‘awssdk-5MB-2’, ‘r’);
$result = $s3->uploadPart(array(
‘Bucket’ => $bucket,
‘Key’ => $keyname,
‘UploadId’ => $uploadId,
‘PartNumber’ => $partNumber,
‘Body’ => fread($file, 10 * 1024 * 1024),
));
fclose($file);

$parts[] = array(
‘PartNumber’ => $partNumber,
‘ETag’ => $result[‘ETag’],
);

$file = fopen(‘awssdk-5MB-1’, ‘r’);
$partNumber = 1;
$result = $s3->uploadPart(array(
‘Bucket’ => $bucket,
‘Key’ => $keyname,
‘UploadId’ => $uploadId,
‘PartNumber’ => $partNumber,
‘Body’ => fread($file, 10 * 1024 * 1024),
));
fclose($file);

$parts[] = array(
‘PartNumber’ => $partNumber,
‘ETag’ => $result[‘ETag’],
);

$parts = array_reverse($parts);

cd /usr/local/src/
wget “http://sourceforge.net/projects/s3tools/files/latest/download?source=files”
mv download\?source\=files s3cmd-1.6.0.tar.gz
tar xvzf s3cmd-1.6.0.tar.gz
cd s3cmd-1.6.0
yum install python-setuptools
python ./setup.py install
s3cmd

 

[nilesflow@tk2-234-26954 glusterfs]$ s3cmd –configure
Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.

Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.
Access Key: xxx
Secret Key: yyy
Default Region [US]: us-west-2

Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password: zzz
Path to GPG program [/usr/bin/gpg]:

When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP, and can only be proxied with Python 2.7 or newer
Use HTTPS protocol [Yes]:

New settings:
Access Key: xxx
Secret Key: yyy
Default Region: us-west-2
Encryption password: zzz
Path to GPG program: /usr/bin/gpg
Use HTTPS protocol: True
HTTP Proxy server name:
HTTP Proxy server port: 0

Test access with supplied credentials? [Y/n] Y
Please wait, attempting to list all buckets…
Success. Your access key and secret key worked fine 🙂

Now verifying that encryption works…
Success. Encryption and decryption worked fine 🙂

Save settings? [y/N] y
Configuration saved to ‘/home/nilesflow/.s3cfg’

 

★PUT

[nilesflow@tk2-234-26954 s3cmd]$ s3cmd put s3cmd.txt s3://nilesflowfirstbucket
‘s3cmd.txt’ -> ‘s3://nilesflowfirstbucket/s3cmd.txt’ [1 of 1]
6 of 6 100% in 0s 72.27 B/s done
‘s3cmd.txt’ -> ‘s3://nilesflowfirstbucket/s3cmd.txt’ [1 of 1]
6 of 6 100% in 0s 42.13 B/s done

 

★マルチパートアップロード 50MB

[nilesflow@tk2-234-26954 s3cmd]$ dd if=/dev/zero of=s3cmd-50MB bs=50MB count=1
1+0 records in
1+0 records out
50000000 bytes (50 MB) copied, 0.191449 s, 261 MB/s
[nilesflow@tk2-234-26954 s3cmd]$ ll

[nilesflow@tk2-234-26954 s3cmd]$ s3cmd put –multipart-chunk-size-mb=5 s3cmd-50MB s3://nilesflowfirstbucket
‘s3cmd-50MB’ -> ‘s3://nilesflowfirstbucket/s3cmd-50MB’ [part 1 of 10, 5MB]
5242880 of 5242880 100% in 0s 14.18 MB/s done
‘s3cmd-50MB’ -> ‘s3://nilesflowfirstbucket/s3cmd-50MB’ [part 2 of 10, 5MB]
5242880 of 5242880 100% in 0s 14.37 MB/s done
‘s3cmd-50MB’ -> ‘s3://nilesflowfirstbucket/s3cmd-50MB’ [part 3 of 10, 5MB]
5242880 of 5242880 100% in 0s 15.60 MB/s done
‘s3cmd-50MB’ -> ‘s3://nilesflowfirstbucket/s3cmd-50MB’ [part 4 of 10, 5MB]
5242880 of 5242880 100% in 0s 12.77 MB/s done
‘s3cmd-50MB’ -> ‘s3://nilesflowfirstbucket/s3cmd-50MB’ [part 5 of 10, 5MB]
5242880 of 5242880 100% in 0s 15.85 MB/s done
‘s3cmd-50MB’ -> ‘s3://nilesflowfirstbucket/s3cmd-50MB’ [part 6 of 10, 5MB]
5242880 of 5242880 100% in 0s 15.12 MB/s done
‘s3cmd-50MB’ -> ‘s3://nilesflowfirstbucket/s3cmd-50MB’ [part 7 of 10, 5MB]
5242880 of 5242880 100% in 0s 18.30 MB/s done
‘s3cmd-50MB’ -> ‘s3://nilesflowfirstbucket/s3cmd-50MB’ [part 8 of 10, 5MB]
5242880 of 5242880 100% in 0s 10.19 MB/s done
‘s3cmd-50MB’ -> ‘s3://nilesflowfirstbucket/s3cmd-50MB’ [part 9 of 10, 5MB]
5242880 of 5242880 100% in 0s 15.32 MB/s done
‘s3cmd-50MB’ -> ‘s3://nilesflowfirstbucket/s3cmd-50MB’ [part 10 of 10, 2MB]
2814080 of 2814080 100% in 0s 5.10 MB/s done