SergioGregorutti's avatar

Error trying to upload a file on Amazon S3

Hi all,

Im trying to upload an image to an Amazon S3 bucket but Im dealing with this error:

Class 'League\Flysystem\AwsS3v3\AwsS3Adapter' not found

In my composer.json file I have:

...
"league/flysystem-aws-s3-v2": "~1.0",
"aws/aws-sdk-php-laravel": "~2.0",
"graham-campbell/flysystem": "~2.1"

An in the controller:

...
    $file = time().'-'.$image->getClientOriginalName();
    $path = 'images/commerces/'.$commerce->id.'/';

        $image = Image::make($image)->widen(800, function ($constraint) {
            $constraint->upsize();
        });
        //$image->save($path . $image);

        Storage::disk('s3')->put($path.$file, $image);

        $commerce->image = $file;
        $commerce->save();
...

Someone can help me with this?

Thanks in advance!

0 likes
7 replies
jimmck's avatar

These test routes work for me.

    Route::get('files', function () {
        // Get a remote list of files.
        $disk = \Storage::disk('s3');
        $files = $disk->allFiles();
        print "<div>";
        foreach ($files as $file) {
            $modified = date(DATE_RFC2822, $disk->lastModified($file));
            $size = $disk->size($file);
            $type = $disk->mimeType($file);
            print "<li> $file : $modified ($size Bytes) : $type</li>";
        }
        print "</div>";
    });

    Route::get('dirs', function () {
        // Get a remote list of files.
        $disk = \Storage::disk('s3');
        $dirs = $disk->allDirectories("./");
        print "<div>";
        foreach ($dirs as $dir) {
            print "<h3> $dir </h3>";
            $files = $disk->files($dir);
            foreach ($files as $file) {
                $modified = date(DATE_RFC2822, $disk->lastModified($file));
                $size = $disk->size($file);
                $type = $disk->mimeType($file);
                print "<li> $file : $modified ($size Bytes) : $type</li>";
            }
        }
        print "</div>";
    });
michaelvolst's avatar
Level 37

In your composer.json your requiring the V2 package but you will be needing the v3 package.

Amazon S3: league/flysystem-aws-s3-v3 ~1.0

1 like
SergioGregorutti's avatar

You are right @michaelvolst.

But, now Im trying to install "league/flysystem-aws-s3-v3 ~1.0" and Im dealing with this issue:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - league/flysystem-aws-s3-v3 1.0.0 requires aws/aws-sdk-php 3.*@dev -> satisfiable by aws/aws-sdk-php[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.1.0, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.3.4, 3.3.5].
    - league/flysystem-aws-s3-v3 1.0.1 requires aws/aws-sdk-php ^3.0.0 -> satisfiable by aws/aws-sdk-php[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.1.0, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.3.4, 3.3.5].
    - league/flysystem-aws-s3-v3 1.0.2 requires aws/aws-sdk-php ^3.0.0 -> satisfiable by aws/aws-sdk-php[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.1.0, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.3.4, 3.3.5].
    - league/flysystem-aws-s3-v3 1.0.3 requires aws/aws-sdk-php ^3.0.0 -> satisfiable by aws/aws-sdk-php[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.1.0, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.3.4, 3.3.5].
    - league/flysystem-aws-s3-v3 1.0.4 requires aws/aws-sdk-php ^3.0.0 -> satisfiable by aws/aws-sdk-php[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.1.0, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.3.4, 3.3.5].
    - aws/aws-sdk-php 3.3.5 requires guzzlehttp/guzzle ~5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.3.4 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.3.3 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.3.2 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.3.1 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.3.0 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.2.6 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.2.5 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.2.4 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.2.3 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.2.2 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.2.1 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.2.0 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.1.0 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.0.7 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.0.6 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.0.5 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.0.4 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.0.3 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.0.2 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.0.1 requires guzzlehttp/guzzle >=5.3|~6.0.1|~6.1 -> no matching package found.
    - aws/aws-sdk-php 3.0.0 requires guzzlehttp/guzzle ^5.3 || ^6.0.1 -> no matching package found.
    - Installation request for league/flysystem-aws-s3-v3 ~1.0 -> satisfiable by league/flysystem-aws-s3-v3[1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.
SergioGregorutti's avatar

@sid405 Yes, sorry. I dont know if I made the correct thing. They are different errors but they are related. I dont know how to delete the other thread.

Im using Laravel 5.1.16

Please or to participate in this conversation.