Symfony 3 Uploading File To S3 Bucket Error

I am using Symfony to upload a file to an amazon bucket. First off I can successfully upload this file to my Amazon bucket using the CLI but when I attempt to do it via Symfony I get this error:

"Error retrieving credentials from the instance profile metadata server. (cURL error 28: Timeout was reached)"

I am using the EXACT same credentials that I am using in the CLI, yet in Symfony, yet I just get errors…

Here’s my code…

            $s3 = new S3Client([
                'key'=>'XXXXXXXXXXXX',
                'secret'=>'XXXXXXXXXXXX',
                'region'=>'us-east-2',
                'version'=>'latest',
            ]);
            $cmd = $s3->getCommand('PutObject', [
                'Bucket' => 'my-bucket-name',
                'Key'    => 'file-name.png',
                'SourceFile' => '/source/file-name.png',
                'ContentType'  => 'image/png',
                'ACL'          => 'public-read',
                'StorageClass' => 'REDUCED_REDUNDANCY'
            ]);
            $result = $s3->execute($cmd);

What am I doing wrong? Thanks.


Source: stackoverflow-php

Set document manager at run time in symfony3 mongodb bundle?

I’m building a multi tenant app with each client having a different database on the same server (mongoDB). I want to set the appropriate client (tenant) database based on an api parameter that will be passed to each request. In other words, the database and document manager should be set at run time based on the tenant’s site from which the request originated. The architecture is such that there’s a single auth database to store the user and allow for authentication and a single user can have separate profiles for different tenants. When the user authenticates, I set a JWT token whose payload includes the identifier of the tenant site. Each subsequent requests, I retrieve the tenant ID and now I want to select the database/document manger of that tenant to be used to handle that request. I’ve looked into several possibilities but I’m not able to come up with a concrete solution to this problem. Has anyone done this before using symfony/mongoDB?


Source: stackoverflow-php