Confirm by changing [ ] to [x] below:
Version of AWS SDK for PHP?
The latest
Aws\Sdk::VERSION in your code composer show -i Version of PHP (php -v)?
The latest
Describe the question
Hi there! I have a question.
I would like to move local folder under ec2 to S3 using PHP SDK. Under every folder, two random files are located so, only folder names I can know. I searched a lot and I found two method: uploadDirectory() and transfer() under transfer class.
Could you let me know the difference between two? I thought that the first one is used with http/https and the last one is used with s3:// protocol.
Many many thanks for your great works!! Have a good one!
I searched and found the code. It uses transfer class both, so it's same :)
Hi @heathera2016, thanks for reaching out to us. As you noted, the transfer() method of the SDK's S3 Transfer Manager effectively does the same as the uploadDirectory() method of the SDK's S3 Client Interface, the primary difference is that the S3 Transfer Manager uses the s3:// URI path in its input instead of specifying the Bucket and Key parameters for the request.
@diehlaws Thank you so much your reply. It's out of topic, however, I would like to know the difference between s3:// URI path and sepcifying the Bucket and Key parameters for the request. I'm searching a lot regarding s3:// protocol, but I couldn't find the exact principle. Before I use the methods(Putobject) or S3:// protocol, I would like to know the difference and principle. Could you explain a bit difference between s3:// protocol and Bucket and Key parameters? I would like to know the principle eagerly. Many thanks and have a good one :)
Sincerely,
Heathera
No problem @heathera2016! Requests that use s3:// URI paths do not use a different protocol than standard PutObject requests - both are sent to S3 over HTTP/S. The PHP SDK's S3 Transfer Manager and S3 Stream Wrapper parse s3:// URIs so that the target bucket and key can be provided as a single string without the end user having to determine the full URL for the S3 Object involved in the request.
Other AWS SDKs also support this style of URI path - the most notable example of this path style's usage is the s3 command set for the AWS CLI since including s3://bucketname/path/to/object as the target for a CLI command is shorter than including the --bucket <bucketname> and --key <path/to/object> parameters.
@diehlaws Many many thanks for your explanation. It helps a lot!! :D Have a good one!! :)
Sincerely,
Heathera
Most helpful comment
No problem @heathera2016! Requests that use
s3://URI paths do not use a different protocol than standardPutObjectrequests - both are sent to S3 over HTTP/S. The PHP SDK's S3 Transfer Manager and S3 Stream Wrapper parses3://URIs so that the target bucket and key can be provided as a single string without the end user having to determine the full URL for the S3 Object involved in the request.Other AWS SDKs also support this style of URI path - the most notable example of this path style's usage is the
s3command set for the AWS CLI since includings3://bucketname/path/to/objectas the target for a CLI command is shorter than including the--bucket <bucketname>and--key <path/to/object>parameters.