Skip to content

Unable to move Image file on EA 3 #5136

@lDeleted

Description

@lDeleted

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);

image

I was based on this SymfonyCasts video: https://symfonycasts.com/screencast/easyadminbundle/upload

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions