How can I download a file from a subfolder in a amazon s3bucket using php?
I have vendor folder in my local.
I want to download a file from a sub folder which is inside my bucket's folder, to my computer's directory with the same name.
Let's say there is a bucket name "ABC" a folder is there inside it, is "DEF" And there is a sub folder named "XYZ" in "DEF". In which the files are present in folder "XYZ".
So, anyone can help me in resolving this?
function downloadFromS3($s3version,$s3region,$s3accesskey,$s3secret,$bucket,$directory){
$s3 = new S3Client([
'version' => $s3version,
'region' => $s3region,
'credentials' =>
array(
'key'=>$s3accesskey,
'secret' =>$s3secret
)
]);
try {
$basePath = 'downloads/';
$s3->downloadBucket($basePath . $directory, $bucket, $directory);
}
catch (AwsS3ExceptionS3Exception $e) {
echo $e->getMessage();
echo "There was an error uploading the file.n";
}
}
I am getting error like
Warning: count(): Parameter must be an array or an object that implements Countable in C:xampphtdocsPerformanceTestManagementvendorguzzlehttpguzzlesrcHandlerCurlFactory.php on line 67
Thanks in advance..
php amazon-s3
add a comment |
I have vendor folder in my local.
I want to download a file from a sub folder which is inside my bucket's folder, to my computer's directory with the same name.
Let's say there is a bucket name "ABC" a folder is there inside it, is "DEF" And there is a sub folder named "XYZ" in "DEF". In which the files are present in folder "XYZ".
So, anyone can help me in resolving this?
function downloadFromS3($s3version,$s3region,$s3accesskey,$s3secret,$bucket,$directory){
$s3 = new S3Client([
'version' => $s3version,
'region' => $s3region,
'credentials' =>
array(
'key'=>$s3accesskey,
'secret' =>$s3secret
)
]);
try {
$basePath = 'downloads/';
$s3->downloadBucket($basePath . $directory, $bucket, $directory);
}
catch (AwsS3ExceptionS3Exception $e) {
echo $e->getMessage();
echo "There was an error uploading the file.n";
}
}
I am getting error like
Warning: count(): Parameter must be an array or an object that implements Countable in C:xampphtdocsPerformanceTestManagementvendorguzzlehttpguzzlesrcHandlerCurlFactory.php on line 67
Thanks in advance..
php amazon-s3
Which version of the SDK are you using?
– Jamie_D
Nov 17 '18 at 15:48
In License, it is given that version 2.0 @Jamie_D
– Prajna Hegde
Nov 19 '18 at 6:06
I strongly suggest upgrading to Version 3 of the Amazon PHP SDK and then follow the client configuration instructions here. Ater that you can use the downloadBucket method
– Jamie_D
Nov 19 '18 at 8:44
Going strictly by the overall look of your client configuration however, it looks like you're using the client configuration method for version 3. If you do not want to upgrade, then you need to configure your client using the V2 Method
– Jamie_D
Nov 19 '18 at 9:02
add a comment |
I have vendor folder in my local.
I want to download a file from a sub folder which is inside my bucket's folder, to my computer's directory with the same name.
Let's say there is a bucket name "ABC" a folder is there inside it, is "DEF" And there is a sub folder named "XYZ" in "DEF". In which the files are present in folder "XYZ".
So, anyone can help me in resolving this?
function downloadFromS3($s3version,$s3region,$s3accesskey,$s3secret,$bucket,$directory){
$s3 = new S3Client([
'version' => $s3version,
'region' => $s3region,
'credentials' =>
array(
'key'=>$s3accesskey,
'secret' =>$s3secret
)
]);
try {
$basePath = 'downloads/';
$s3->downloadBucket($basePath . $directory, $bucket, $directory);
}
catch (AwsS3ExceptionS3Exception $e) {
echo $e->getMessage();
echo "There was an error uploading the file.n";
}
}
I am getting error like
Warning: count(): Parameter must be an array or an object that implements Countable in C:xampphtdocsPerformanceTestManagementvendorguzzlehttpguzzlesrcHandlerCurlFactory.php on line 67
Thanks in advance..
php amazon-s3
I have vendor folder in my local.
I want to download a file from a sub folder which is inside my bucket's folder, to my computer's directory with the same name.
Let's say there is a bucket name "ABC" a folder is there inside it, is "DEF" And there is a sub folder named "XYZ" in "DEF". In which the files are present in folder "XYZ".
So, anyone can help me in resolving this?
function downloadFromS3($s3version,$s3region,$s3accesskey,$s3secret,$bucket,$directory){
$s3 = new S3Client([
'version' => $s3version,
'region' => $s3region,
'credentials' =>
array(
'key'=>$s3accesskey,
'secret' =>$s3secret
)
]);
try {
$basePath = 'downloads/';
$s3->downloadBucket($basePath . $directory, $bucket, $directory);
}
catch (AwsS3ExceptionS3Exception $e) {
echo $e->getMessage();
echo "There was an error uploading the file.n";
}
}
I am getting error like
Warning: count(): Parameter must be an array or an object that implements Countable in C:xampphtdocsPerformanceTestManagementvendorguzzlehttpguzzlesrcHandlerCurlFactory.php on line 67
Thanks in advance..
php amazon-s3
php amazon-s3
edited Nov 17 '18 at 11:30
Ali
355314
355314
asked Nov 17 '18 at 11:06
Prajna HegdePrajna Hegde
157118
157118
Which version of the SDK are you using?
– Jamie_D
Nov 17 '18 at 15:48
In License, it is given that version 2.0 @Jamie_D
– Prajna Hegde
Nov 19 '18 at 6:06
I strongly suggest upgrading to Version 3 of the Amazon PHP SDK and then follow the client configuration instructions here. Ater that you can use the downloadBucket method
– Jamie_D
Nov 19 '18 at 8:44
Going strictly by the overall look of your client configuration however, it looks like you're using the client configuration method for version 3. If you do not want to upgrade, then you need to configure your client using the V2 Method
– Jamie_D
Nov 19 '18 at 9:02
add a comment |
Which version of the SDK are you using?
– Jamie_D
Nov 17 '18 at 15:48
In License, it is given that version 2.0 @Jamie_D
– Prajna Hegde
Nov 19 '18 at 6:06
I strongly suggest upgrading to Version 3 of the Amazon PHP SDK and then follow the client configuration instructions here. Ater that you can use the downloadBucket method
– Jamie_D
Nov 19 '18 at 8:44
Going strictly by the overall look of your client configuration however, it looks like you're using the client configuration method for version 3. If you do not want to upgrade, then you need to configure your client using the V2 Method
– Jamie_D
Nov 19 '18 at 9:02
Which version of the SDK are you using?
– Jamie_D
Nov 17 '18 at 15:48
Which version of the SDK are you using?
– Jamie_D
Nov 17 '18 at 15:48
In License, it is given that version 2.0 @Jamie_D
– Prajna Hegde
Nov 19 '18 at 6:06
In License, it is given that version 2.0 @Jamie_D
– Prajna Hegde
Nov 19 '18 at 6:06
I strongly suggest upgrading to Version 3 of the Amazon PHP SDK and then follow the client configuration instructions here. Ater that you can use the downloadBucket method
– Jamie_D
Nov 19 '18 at 8:44
I strongly suggest upgrading to Version 3 of the Amazon PHP SDK and then follow the client configuration instructions here. Ater that you can use the downloadBucket method
– Jamie_D
Nov 19 '18 at 8:44
Going strictly by the overall look of your client configuration however, it looks like you're using the client configuration method for version 3. If you do not want to upgrade, then you need to configure your client using the V2 Method
– Jamie_D
Nov 19 '18 at 9:02
Going strictly by the overall look of your client configuration however, it looks like you're using the client configuration method for version 3. If you do not want to upgrade, then you need to configure your client using the V2 Method
– Jamie_D
Nov 19 '18 at 9:02
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53350595%2fhow-can-i-download-a-file-from-a-subfolder-in-a-amazon-s3bucket-using-php%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53350595%2fhow-can-i-download-a-file-from-a-subfolder-in-a-amazon-s3bucket-using-php%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Which version of the SDK are you using?
– Jamie_D
Nov 17 '18 at 15:48
In License, it is given that version 2.0 @Jamie_D
– Prajna Hegde
Nov 19 '18 at 6:06
I strongly suggest upgrading to Version 3 of the Amazon PHP SDK and then follow the client configuration instructions here. Ater that you can use the downloadBucket method
– Jamie_D
Nov 19 '18 at 8:44
Going strictly by the overall look of your client configuration however, it looks like you're using the client configuration method for version 3. If you do not want to upgrade, then you need to configure your client using the V2 Method
– Jamie_D
Nov 19 '18 at 9:02