-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Hi!
I'm trying to upload an image to my S3 bucket, but EA's ImageField() class's setUploadDir() option takes any value for me as a local path. Example:
If I pass it setUploadDir('public/images/users'), it takes it as '%root_project_local%/public/images/users'..
It automatically takes it as a local path, and won't let me move it to my bucket
My script:
yield ImageField::new('image')
->setBasePath('%app.uploads_base_url%') // <--- Here is the root path of my bucket.. (https://myBucket.s3.us-east-1.amazonaws.com
->setUploadDir('public/images/users')
->setFormTypeOption('upload_new', function($file, $uploadDir, $filename) {
$uploadDir = $this->getParameter('app.user_prefix'); // <--- I had to manually burn this value here, but I don't know if it's a good practice.
$filename = $file->getClientOriginalName();
$result = $file->move($uploadDir, $filename); // <--- Output: Unable to create the "https://myBucket.s3.us-east-1.amazonaws.com/public/images/users" directory.
})
->setUploadedFileNamePattern('[slug]-[uniqid].[extension]')
->setRequired(false);I was based on this SymfonyCasts video: https://symfonycasts.com/screencast/easyadminbundle/upload
Metadata
Metadata
Assignees
Labels
No labels
