aws / aws-sdk-php-zf2

ZF2 module for using the AWS SDK for PHP to interact with AWS services like S3, DynamoDB, SQS, EC2, etc.
http://aws.amazon.com/sdkforphp/
Apache License 2.0
103 stars 63 forks source link

Q: How to configure the part_size option (S3) #40

Closed basz closed 8 years ago

basz commented 8 years ago

How do i configure the part_size option of the S3 adapter? I might need to increase it to get a 'real' etag md5 hash.

cjyclaire commented 8 years ago

@basz , just add it in configuration option will work:

$source = '/path/to/large/file.zip';
$size = 6 * 1024 * 1024; // 6MB, default is 5MB
$uploader = new MultipartUploader($s3Client, $source, [
    'bucket' => 'your-bucket',
    'key'    => 'my-file.zip',
    'part_size' => $size
]);
basz commented 8 years ago

Yes, what I actually meant to ask was how to configure this method when using the client upload method... Used as here: https://github.com/thephpleague/flysystem-aws-s3-v3/blob/master/src/AwsS3Adapter.php#L569

But upon deeper infection I think the objectuploader handler this with the mup_threshold setting. Unfortunatly getting the size won't work on remote streams, so even when I hardcode the setting multipart uploads will be done, resulting in the 'md5-x' etag format.

https://github.com/aws/aws-sdk-php/blob/master/src/S3/ObjectUploader.php#L116-L120

I have found that s3cmd cp fileX fileX will change the etag from 'md5-x' to 'md5', so I think I'll write a script to do that...