Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best way to integrate with S3 v3? (yii2-flysystem is outdated) #64

Closed
iadj opened this issue Feb 13, 2016 · 6 comments
Closed

Best way to integrate with S3 v3? (yii2-flysystem is outdated) #64

iadj opened this issue Feb 13, 2016 · 6 comments

Comments

@iadj
Copy link

iadj commented Feb 13, 2016

yii2-flysystem doesn't support flysystem-aws-s3-v3, and the yii2-flysystem package hasn't been updated for nearly a year.

What's currently the most efficient way to integrate flysystem-aws-s3-v3 with yii2-file-kit?

@trntv
Copy link
Collaborator

trntv commented Mar 11, 2016

You can create your own flysystem builder class.
I'll update docs as soon as possible

@trntv
Copy link
Collaborator

trntv commented Mar 11, 2016

@trntv trntv closed this as completed Mar 11, 2016
@iadj
Copy link
Author

iadj commented Mar 11, 2016

Awesome. Thank you for the examples!

@iadj
Copy link
Author

iadj commented Mar 11, 2016

@trntv I still get the same error as described in yii-starter-kit/yii2-starter-kit#371:

fstat() expects parameter 1 to be resource, integer given.

Using AwsS3v3FlysystemBuilder from the examples: https://github.com/trntv/yii2-file-kit/blob/master/examples/AwsS3v3FlysystemBuilder.php

@trntv
Copy link
Collaborator

trntv commented Mar 11, 2016

update package
0cdc678

@iadj
Copy link
Author

iadj commented Mar 11, 2016

@trntv Ok, the error is now:

fstat() expects parameter 1 to be resource, object given.
file: "D:\app\vendor\league\flysystem\src\Util.php"
line: 254

Am I doing something wrong? This is my Storage config:

    'fileStorage' => [
        'class' => '\trntv\filekit\Storage',
        'baseUrl' => '  https://s3.amazonaws.com/' . getenv('S3_PROFILE_BUCKET'),
        'filesystem' => [
          'class' => 'common\components\filesystem\AwsS3v3FlysystemBuilder',
          'key'=>getenv('S3_KEY'),
          'secret'=>getenv('S3_SECRET'),
          'region' => 'us-east-1',
        ],

        'as log' => [
            'class' => 'common\behaviors\FileStorageLogBehavior',
            'component' => 'fileStorage'
        ]

AwsS3v3FlysystemBuilder is like the example.

I can see the file is uploaded to the bucket and correctly added to file_storage_item. However the 'upload process' in yii2-starter-kit never seems to finish, and returns the error described above.

Here's a stack trace:

0: "#0 [internal function]: yii\base\ErrorHandler->handleError(2, 'fstat() expects...', 'D:\\app...', 254, Array)"
1: "#1 D:\app\vendor\league\flysystem\src\Util.php(254): fstat(Object(Intervention\Image\Image))"
2: "#2 D:\app\vendor\league\flysystem-aws-s3-v3\src\AwsS3Adapter.php(557): League\Flysystem\Util::getStreamSize(Object(Intervention\Image\Image))"
3: "#3 D:\app\vendor\league\flysystem-aws-s3-v3\src\AwsS3Adapter.php(121): League\Flysystem\AwsS3v3\AwsS3Adapter->upload('1/cD84EtMmnB6CW...', Object(Intervention\Image\Image), Object(League\Flysystem\Config))"
4: "#4 D:\app\vendor\league\flysystem\src\Filesystem.php(96): League\Flysystem\AwsS3v3\AwsS3Adapter->update('1/cD84EtMmnB6CW...', Object(Intervention\Image\Image), Object(League\Flysystem\Config))"
5: "#5 D:\app\vendor\league\flysystem\src\File.php(94): League\Flysystem\Filesystem->put('1/cD84EtMmnB6CW...', Object(Intervention\Image\Image))"
6: "#6 D:\app\frontend\modules\user\controllers\DefaultController.php(41): League\Flysystem\File->put(Object(Intervention\Image\Image))"
7: "#7 [internal function]: frontend\modules\user\controllers\DefaultController->frontend\modules\user\controllers\{closure}(Object(trntv\filekit\events\UploadEvent))"
8: "#8 D:\app\vendor\yiisoft\yii2\base\Component.php(541): call_user_func(Object(Closure), Object(trntv\filekit\events\UploadEvent))"
9: "#9 D:\app\vendor\trntv\yii2-file-kit\src\actions\UploadAction.php(167): yii\base\Component->trigger('afterSave', Object(trntv\filekit\events\UploadEvent))"
10: "#10 D:\app\vendor\trntv\yii2-file-kit\src\actions\UploadAction.php(132): trntv\filekit\actions\UploadAction->afterSave('1/cD84EtMmnB6CW...')"
11: "#11 [internal function]: trntv\filekit\actions\UploadAction->run()"
12: "#12 D:\app\vendor\yiisoft\yii2\base\Action.php(92): call_user_func_array(Array, Array)"
13: "#13 D:\app\vendor\yiisoft\yii2\base\Controller.php(154): yii\base\Action->runWithParams(Array)"
14: "#14 D:\app\vendor\yiisoft\yii2\base\Module.php(454): yii\base\Controller->runAction('avatar-upload', Array)"
15: "#15 D:\app\vendor\yiisoft\yii2\web\Application.php(84): yii\base\Module->runAction('user/default/av...', Array)"
16: "#16 D:\app\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))"
17: "#17 D:\app\frontend\web\index.php(22): yii\base\Application->run()"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants