Comments (2)
Hi @alaskancode, sorry to hear about your issue. I understand that some improvements could be done here for resolving paths depending on running environment, and this is something I will bring up to the team for discussion. However, there are some alternatives that you can use now for solving this issue and some of them are in the link that you posted already. If you properly set a value for AWS_SHARED_CREDENTIALS_FILE with a location of your preference then, you should have not issues if that location is a valid path and the file is a valid credentials one. I know the docs recommends using setx, but if that did not work then, you may need to check on your environment what is preventing that variable from being set. We can check here that we look at that variable value first and if is set then we give preference to that value over the default one. Windows also has another ways to set environment variables and I encourage you to try them. Below you can see a short example where I set AWS_SHARED_CREDENTIALS_FILE to a custom location and the SDK tried to use that one. Please see below:
<?php
require '../vendor/autoload.php';
use Aws\Credentials\CredentialProvider;
use Aws\S3\S3Client;
putenv("AWS_SHARED_CREDENTIALS_FILE='./mysharedcredsfile'");
$client = new S3Client([
'region' => 'us-east-2',
'credentials' => CredentialProvider::ini()
]);
$client->listBuckets();
Here is the output:
PHP Fatal error: Uncaught Aws\Exception\CredentialsException: Cannot read credentials from './mysharedcredsfile' in $PROJECT_DIR/src/Credentials/CredentialProvider.php:826
Stack trace:
...
Another solution for your issue is to provide the credentials file location explicitly to the credential provider as follow:
<?php
require '../vendor/autoload.php';
use Aws\Credentials\CredentialProvider;
use Aws\S3\S3Client;
$credentialsFilePath = 'YOUR_CUSTOM_CREDENTIALS_FILE_PATH';
$provider = CredentialProvider::ini(null, $credentialsFilePath);
$memoizedProvider = CredentialProvider::memoize($provider);
$s3Client = new S3Client([
'region' => 'us-east-1',
'credentials' => $memoizedProvider
]);
$s3Client->listBuckets();
Please let me know if that helps!
Thanks!
from aws-sdk-php.
This issue has not recieved a response in 1 week. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.
from aws-sdk-php.
Related Issues (20)
- Deprecated: Using ${var} in strings is deprecated HOT 3
- Support 'OriginationNumber' when sending SMS. HOT 1
- Exception thrown in synchronous call "bleeds over" to asynchronous call HOT 3
- IRSA for Kubernetes not working HOT 3
- Argument 4 passed to Aws\Exception\AwsException::__construct() must be an instance of Exception or null HOT 3
- verifyDomainDkim method of SES Client returns validation error HOT 4
- Yum package
- InstanceProfile credentials provider causing open_basedir restriction error since 3.297.0 HOT 2
- Aws SQS: VisibilityTimeout value is zero and type is string instead integer HOT 5
- What version should I specify for MediaPackage and MediaPackageVod client? HOT 3
- PostObjectV4 with Custom Domain HOT 5
- fopen() throws Error executing "GetObject" HOT 1
- GetObject() command @http stream issue HOT 3
- Error when trying to list objects from a public S3 bucket via the listObjectsV2() function. HOT 2
- S3 PutObject doesn't work on VPN HOT 1
- ObjectUploader fails for files >16mb with Aws\S3\Exception\S3MultipartUploadException HOT 2
- S3Client: `upload()` returns differently encoded `ObjectURL`, depending on the uploaded file size (e.g. `%2F` instead of `/`) HOT 1
- Version 3.311.0 always triggers “Aws\\Command::setAuthSchemes is deprecated” HOT 8
- Intermittently getting EndpointDiscoveryException's thrown when attempting to write records to timestream.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-sdk-php.