I just upgraded from V2 to V3. My V2 uploadDirectory() call looked like:
$s3Client>uploadDirectory( '/path/to/local',
'kushbucket', '/path/to/s3/location', array(
'params' => array(
'ACL' => 'public-read',
'ContentDisposition' => 'attachment'
)
)
);
I read http://docs.aws.amazon.com/aws-sdk-php/v3/api/class-Aws.S3.S3Client.html#_uploadDirectory which tells me to go to http://docs.aws.amazon.com/aws-sdk-php/v3/api/class-Aws.S3.Transfer.html#___construct for options and customizations. But I don't see anything on the second page on how to change the ACL and ContentDisposition.
You can pass a callback as the before option to the transfer manager constructor. The callback can modify the UploadPart and CreateMultipartUpload commands to support custom metadata as needed. This approach allows more flexibility than passing in custom options, as you might want to set cache control metadata based on file extension or otherwise tailor your options to the specific file being uploaded.
Hope that helps! Please feel free to reopen if you have any questions or concerns.
That did the trick. For anyone else wondering what the end code look like:
$s3Client>uploadDirectory( '/path/to/local',
'kushbucket', '/path/to/s3/location', array(
'before' => function(\AWS\Command $command){
$command['ACL'] = 'public-read';
$command['ContentDisposition'] = 'attachment';
},
)
);
Is there a complete list of all keys \AWS\Command accepts? In my V2 code, I also had an explicit "multipart_upload_size" => 1000 declaration. How do I set a custom multipart upload size threshold in V3?
The keys would differ from command to command. Any option that could be passed to a direct call of a command can be accessed and modified as a key on the command object. For the transfer manager, all commands passed to the before callback will be a PutObject command, a CreateMultipartUpload command, an UploadPart command, or a CompleteMultipartUpload command.
You can control what the minimum size to trigger a multipart upload is with the mup_threshold option passed to the transfer manager's constructor.
Most helpful comment
That did the trick. For anyone else wondering what the end code look like:
Is there a complete list of all keys \AWS\Command accepts? In my V2 code, I also had an explicit
"multipart_upload_size" => 1000declaration. How do I set a custom multipart upload size threshold in V3?