Chapters
40 Chapters
|
4:39:58
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.1.3
Subscribe to download the code!Compatible PHP versions: ^7.1.3
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
36.
S3 & Private Object via ACLs
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial is built on Symfony 4 but works great in Symfony 5!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"aws/aws-sdk-php": "^3.87", // 3.87.10
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/annotations": "^1.0", // 1.10.1
"doctrine/doctrine-bundle": "^1.6.10", // 1.10.2
"doctrine/doctrine-migrations-bundle": "^1.3|^2.0", // v2.0.0
"doctrine/orm": "^2.5.11", // v2.7.2
"knplabs/knp-markdown-bundle": "^1.7", // 1.7.1
"knplabs/knp-paginator-bundle": "^2.7", // v2.8.0
"knplabs/knp-time-bundle": "^1.8", // 1.9.0
"league/flysystem-aws-s3-v3": "^1.0", // 1.0.22
"league/flysystem-cached-adapter": "^1.0", // 1.0.9
"liip/imagine-bundle": "^2.1", // 2.1.0
"nexylan/slack-bundle": "^2.0,<2.2.0", // v2.1.0
"oneup/flysystem-bundle": "^3.0", // 3.0.3
"php-http/guzzle6-adapter": "^1.1", // v1.1.1
"phpdocumentor/reflection-docblock": "^3.0|^4.0", // 4.3.0
"sensio/framework-extra-bundle": "^5.1", // v5.2.4
"stof/doctrine-extensions-bundle": "^1.3", // v1.3.0
"symfony/asset": "^4.0", // v4.2.3
"symfony/console": "^4.0", // v4.2.3
"symfony/flex": "^1.9", // v1.21.6
"symfony/form": "^4.0", // v4.2.3
"symfony/framework-bundle": "^4.0", // v4.2.3
"symfony/property-access": "4.2.*", // v4.2.3
"symfony/property-info": "4.2.*", // v4.2.3
"symfony/security-bundle": "^4.0", // v4.2.3
"symfony/serializer": "4.2.*", // v4.2.3
"symfony/twig-bundle": "^4.0", // v4.2.3
"symfony/validator": "^4.0", // v4.2.3
"symfony/web-server-bundle": "^4.0", // v4.2.3
"symfony/yaml": "^4.0", // v4.2.3
"twig/extensions": "^1.5" // v1.5.4
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0", // 3.1.0
"easycorp/easy-log-handler": "^1.0.2", // v1.0.7
"fzaninotto/faker": "^1.7", // v1.8.0
"symfony/debug-bundle": "^3.3|^4.0", // v4.2.3
"symfony/dotenv": "^4.0", // v4.2.3
"symfony/maker-bundle": "^1.0", // v1.11.3
"symfony/monolog-bundle": "^3.0", // v3.3.1
"symfony/phpunit-bridge": "^3.3|^4.0", // v4.2.3
"symfony/stopwatch": "4.2.*", // v4.2.3
"symfony/var-dumper": "^3.3|^4.0", // v4.2.3
"symfony/web-profiler-bundle": "4.2.*" // v4.2.3
}
}
5 Comments
Hello ! With the latest versions, we no longer have the AdapterInterface class, so we cannot run the following code:
Is there an alternative ?
<b>EDIT</b> : I thought of simply putting 'public' or 'private' rather than using constants from AdapterInterface (non-existent on the latest version).
But by digging a bit I found the <b>League\Flysystem\Visibility</b> class
It also contains two constants which do exactly the same thing.
I imagine this is the class that is used to replace the AdapterInterface?
Hey Kiuega
You are right! That will work! :)
Cheers!
So I seem to be having some issues with this tutorial. I am adapting your tutorial, and instead of uploading public article images, I am attempting to upload public user profile pictures. I have been following the tutorial so far and everything is going great locally. I upload an image using Flysystem, and it works like a charm. Imagine bundle then grabs it, does its thing and puts them in the specified thumbnails folders.
Then, when I send my code up to my EC2 instance, it appears to be working but no.. Flysystem takes the file and uploads it to S3, no problem. Imagine Bundle though does not upload any of the thumbnails, but DOES try to read them as if they are there, so my site has a bunch of broken links. I have gone in to the AWS Policy checker to make sure the Id and Secret I use have access to the bucket and it all checks out. I have removed all the security options on my testing S3 bucket to make sure any of those are stopping the thumbnail uploads, and it still doesn't put the files in.
I'm running out of Ideas! Any thing you can recommend?
Here are some configs for you for context.
My latest attempt, I was creating a separate filesystem with hardcoded public visibility. Normally I just use the uploads_filesystem
oneup_flysystem.yaml
Imagine Bundle config, again set up with my most recent attempt to force a seperate public filesystem specifically for imagine.
My uploads manager is literally straight out of your tutorial with no changes other then I'm focusing on user photos and not article images and references.
Props to Kiuega below for the Visibility tip.
UGh.. I thought I proof read before I posted. I should have stated that I do have the S3 Client credentials commented out due to already having another account set up on the EC2 box for my AWS Secrets Manager service. I am using the same user to bring in all the different policies for AWS. By not providing the credentials it just defaults to the authenticated already established IAM User... I think... I read that somewhere.. Anyways, its working locally, just not on staging.
Hey @Mathew!
Darn! So close that you have it working locally... but not on staging!
Ok, so this is the part we need to debug. And this can be tricky. Remember, there are two possible URLs that ImagineBundle might output. They are of the form:
A)
/media/cache/resolve/squared_thumbnail_small/...(taken from the tutorial example: https://symfonycasts.com/screencast/symfony-uploads/thumbnailing). This is NOT meant to be the real path to a real image: this is path to a Symfony route/controller whose job it is to thumbnail and upload the thumbnail to its final location. In theory, this path would render just ONE time (the first time a thumbnail is rendered). Every other time after (since the thumbnail will now already be created), then next pat his rendered:B)
https://some.path.to/the/real/physical/image. For you, this would be a URL to S3.You mentioned that the thumbnails are failing to UPLOAD to S3 (vs they ARE being uploaded, but you can't access them). This means that something is going wrong when the (A) URL is rendered. If you can, try to isolate (and then copy) a URL in the (A) format. Depending on how things are setup, you might only see this once right after uploading an image, or you may ONLY see this URL form (since the system may correctly be realizing that the thumbnails did NOT upload... and so it's trying again and again and again).
Anyways, once you have this URL, you can paste it into your browser and start debugging. Ideally you can hack some code onto your staging server to see what's going wrong. If you can put your staging server into the "dev" environment, you may even be able to tail
var/logs/dev.log: there could be details about what's going wrong there. For debugging code, I'd put some dd() statements into some core classes, like https://github.com/liip/LiipImagineBundle/blob/2.x/Binary/Loader/FlysystemLoader.php or https://github.com/liip/LiipImagineBundle/blob/2.x/Imagine/Cache/Resolver/FlysystemResolver.php#L118That's some, somewhat generic instructions. But let me know if it helps you get anywhere :).
Cheers!
"Houston: no signs of life"
Start the conversation!