opheliadesign's avatar

S3 filesystem in 5.1?

Hi everyone,

I upgraded to Lumen 5.1 recently and now I'm getting an error when trying to use Amazon S3. I also cannot find any mention of the filesystem in the Lumen docs - was a lot of stuff taken out??

$app->get('image-test', function() {
    $disk = \Storage::disk('s3');
    $image = Image::make("https://demo.com/image.jpg");
    $image->orientate();
    $image->resize(1024, 748, function ($constraint) {
        $constraint->aspectRatio();
    });
    $image->encode('jpg');
    $filename = str_random() . '.jpg';
    $url = "incident-images/kANSmjocyToM8QpGQiIX/mms/$filename";
    $disk->put($url, $image);
});

Error message is:

Fatal error: Class 'League\Flysystem\AwsS3v3\AwsS3Adapter' not found in /home/vagrant/cvahimt-api/vendor/illuminate/filesystem/FilesystemManager.php on line 159

I know for a fact that this used to work, I have the following in composer.json:

"league/flysystem-aws-s3-v2": "~1.0",
    "league/flysystem-rackspace": "~1.0",

I also have FILESYSTEM_CLOUD=s3 in my .env, along with my S3 credentials.

0 likes
4 replies
opheliadesign's avatar

The clue should have been that the error said it was looking for AwsS3v3 and I had AwsS3v2 installed - must have missed that somewhere.

But I'm curious, what happened to the Lumen docs?? I'm pretty sure there used to be setup instructions for cloud storage.

1 like
tomfilepp's avatar

Good catch--- took me a few minutes to realize this myself. Was following some installation docs I found on the web, but they were outdated, it seems.

1 like
jimmck's avatar

No its available. Remember to install the config mod. Thanks to @tymondesigns

        "laravel/lumen-framework": "5.1.*",
        "aws/aws-sdk-php-laravel": "~3.0",
        "vlucas/phpdotenv": "~1.0",
        "tymon/jwt-auth": "^0.5.3",
        "cboden/ratchet": "0.3.*",
        "react/zmq": "0.2.*|0.3.*",
        "basicit/lumen-vendor-publish": "^1.0",
        "guzzle/guzzle": "^3.9",
        "videlalvaro/php-amqplib": "2.2.*",
        "barryvdh/laravel-dompdf": "0.6.*",
        "league/flysystem-aws-s3-v3": "^1.0",
        "appzcoder/lumen-routes-list": "dev-master",
        "vluzrmos/collective-html": "^1.0"

config info...

http://laravelista.com/json-web-token-authentication-for-lumen/

And my app.php


$app->register('Tymon\JWTAuth\Providers\JWTAuthServiceProvider');
$app->register('Aws\Laravel\AwsServiceProvider');
$app->register(Appzcoder\LumenRoutesList\RoutesCommandServiceProvider::class);
$app->register(Collective\Html\HtmlServiceProvider::class);


class_alias('Aws\Laravel\AwsFacade', 'AWS');
class_alias('Collective\Html\HtmlFacade', 'HTML');
class_alias('Collective\Html\FormFacade', 'Form');
jimmck's avatar

I am using the AWS stuff...

$app->get('s3send', function () use ($app) {
    print 'HHHHHHHHHHHHHH';
    $s3 = \AWS::createClient('s3');
    //$s3 = AWS::get('s3');
    $result = $s3->putObject(array ('Bucket' => 'jimmck-holmdel', 'Key' => 'test.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";
});

Please or to participate in this conversation.