Can you show your configuration and code ?
L5 S3 Filesystem Bug?
Curious if anyone else has run into an issue using S3 Filesystem in Laravel 5.
The problem: CURL was throwing an error that it could not resolve the host: bucket.s3.Oregon.amazonaws.com
After troubleshooting for a bit I decided to remove the region from the URL since all code examples using CURL on the S3 URL didn't include the region. To accomplish this, I simply removed the region key from the Filesystem config array.
bucket.s3.amazonaws.com - it worked!
Am I doing something wrong and not understanding something correctly or is this indeed a bug.
Thanks,
Travis
If you'd like sure but I pretty much described what happens. I can successfully upload a file if I remove the 'region' key from the array.
Top config example works, bottom config example does not. Implementation below all the configuration information. A pretty simple test.
Hi, Nice to see another AWS Laravel developer. I never took advantage of the buckets before. I went up to my console and created a bucket. My instance is in Oregon. When reading the docs, the region name points to the server farm region you are hosted in. Is faster to access a resource on the same network. The URL points to the s3 storage server our buckets reside in. The bucket name we create has to be unique across the server. I could not reuse your bucket name in the example. Question, Is the key you use, the one you created when you generated your server? I cannot find a way to generate a key for my bucket. Also I would like to access my bucket through api's in my instance. Here are my AWS stats for server: 8GB Micro Instance My-SQL MongoDB ZeroMQ RabbbitMQ PHP-5.6.3 Laravel 4.2 (Getting ready to move).
Just tried to access via Transmit app and it does not like my key?
Dev Env: MAC -Yosemite PHP 5.6.3 PHPStorm MYSQL MongoDB Adobe Suite Coda/Transmit DBVisualizer (Can access AWS MySQL via ssh-tunnel and Key)
It would be nice to share any AWS experience. I have had lots of fun. Regards, Jim
@travisneids I think the problem is your bucket region. Oregon region code is us-west-2
Hi, The URL is s3.amazonaws.com Your generated access key and secret key will point to the bucket you created. I am using the Mac App Transmit to open a s3 connection and view my created bucket and folders I created.
@jimmck where are you get your key? You can access a S3 bucket via 2 type of key. Your account master key or an iam key you generated with permission to access your bucket
I generate the key via my amazon console. do you know how anyone installs the aws s3 require? composer update just generates the following error: [RuntimeException] Could not load package psy/psysh in http://packagist.org: [UnexpectedValueE xception] Could not parse version constraint ^2.4.2: Invalid version string "^2.4.2"
for this composer.json entry "aws/aws-sdk-php-laravel": "1.1.*"
i am trying to install for laravel 4.2
anyone??? This require does not work.
just an fyi. Could not get the file system to work using laravel 4 service see above.
Here is working sample code from Amazon for PHP
require 'app/aws.phar'; use Aws\Common\Aws;// Create the AWS service builder, providing the path to the config file $aws = Aws::factory('s3.php'); $s3Client = $aws->get('s3');
// Upload an object to Amazon S3 $bucket = 'jimmck-holmdel'; //$result = $s3Client->createBucket(array ('Bucket' => $bucket, //'LocationConstraint' => 'us-west-2',));
// Poll the bucket until it is accessible //$s3Client->waitUntil('BucketExists', array ('Bucket' => $bucket)); // Get the Location header of the response //echo $result['Location'] . "\n"; // Get the request ID //echo $result['RequestId'] . "\n";
$result = $s3Client->putObject(array ('Bucket' => $bucket, 'Key' => 'data.txt', 'Body' => 'Hello!'));
// Access parts of the result object echo $result['Expiration'] . "\n"; echo $result['ServerSideEncryption'] . "\n"; echo $result['ETag'] . "\n"; echo $result['VersionId'] . "\n"; echo $result['RequestId'] . "\n"; // Get the URL the object can be downloaded from echo $result['ObjectURL'] . "\n";
s3.php is the config file containing your AWS Key ID, Secret Key and Region.
Works fine.
If anyone knows of why the composer update fails, would appreciate it.
Jim
Got it working!!!! I had setup my composer.json like this to avoid composer errors:
"psy/psysh": "@stable",
"aws/aws-sdk-php": "@stable",
"aws/aws-sdk-php-laravel": "1.1.2"
The created a simple function route and called s3
Route::get('lissa', function()
{
print 'HHHHHHHHHHHHHH';
$s3 = AWS::get('s3');
$result = $s3->putObject(array ('Bucket' => 'jimmck-holmdel',
'Key' => 'melissa.txt',
'Body' => 'Hi!!!!!'
,));
echo $result['Expiration'] . "\n";
echo $result['ServerSideEncryption'] . "\n";
echo $result['ETag'] . "\n";
echo $result['VersionId'] . "\n";
echo $result['RequestId'] . "\n";
// Get the URL the object can be downloaded from
echo $result['ObjectURL'] . "\n";
});
You might want to throw this information into another thread since my is directly related to Laravel 5 and your solution works for Laravel 4.2.
If you want to use something like "oregon" set your region like this.
's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET_KEY'),
'region' => Aws\Common\Enum\Region::OREGON,
'bucket' => 'app-images',
],
https://github.com/aws/aws-sdk-php/blob/master/src/Aws/Common/Enum/Region.php
@kreitje @travisneids I was having the same issue and setting S3_REGION=Aws\Common\Enum\Region::US_EAST_1 resolved it. Thanks!
@jimmck just run composer self-update to get that bug fixed.
It was a year ago and I just started implementing S3 in a new application. Enums for the win @digitalagua !! Thanks brother! That is the way it should be done so I marked your answer as the best answer.
Please or to participate in this conversation.