Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8714033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:29:29+00:00 2026-06-13T05:29:29+00:00

I have an Attachment Entity in Doctrine which references a file on Amazon S3.

  • 0

I have an Attachment Entity in Doctrine which references a file on Amazon S3. I need to be able to provide a sort of ‘Calculated Field’ on the Entity that works out what I call the downloadpath. The downloadpath would be a calculated URL, for example http://site.s3.amazon.com/%s/attach/%s where I need to replace the two string values with values on the entity itself (account and filename), so;

http://site.s3.amazon.com/1/attach/test1234.txt

Although we use a Service Layer, I’d like the downloadpath to be available on the Entity at all times without it having to pass through the SL.

I’ve considered the obvious route of adding say a constant to the Entity;

const DOWNLOAD_PATH = 'http://site.s3.amazon.com/%s/attach/%s'; and a custom getDownloadPath() but I’d like to keep specifics like this URL in my app’s configuration, not the Entities class (also, see update below)

Does anyone have any ideas on how I could achieve this?

UPDATE To add to this, I am aware now that I would need to generate a temporary URL with the AmazonS3 library to allow temporary authed access to the file – I’d prefer not to make a static call to our Amazon/Attachment Service to do this as It just doesn’t feel right.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:29:30+00:00Added an answer on June 13, 2026 at 5:29 am

    Turns out the cleanest way to do this is using the postLoad event like so;

    <?php
    
    namespace My\Listener;
    
    use Doctrine\Common\EventSubscriber;
    use Doctrine\ORM\Events;
    use Doctrine\ORM\Event\LifecycleEventArgs;
    use My\Entity\Attachment as AttachmentEntity;
    use My\Service\Attachment as AttachmentService;
    
    class AttachmentPath implements EventSubscriber
    {
        /**
         * Attachment Service
         * @param \My\Service\Attachment $service
         */
        protected $service;
    
        public function __construct(AttachmentService $service)
        {
            $this->service = $service;
        }
    
        public function getSubscribedEvents()
        {
            return array(Events::postLoad);
        }
    
        public function postLoad(LifecycleEventArgs $args)
        {
            $entity = $args->getEntity();
    
            if ($entity instanceof AttachmentEntity) {
                $entity->setDownloadPath($this->service->getDownloadPath($entity));
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file attachment class (FileAttachment) which is used in several other classes.
I have an email attachment form that is working fine when the <form action=processingtheformfile.php>
I have a GalleryPhoto model with a paperclip attachment that gets processed into a
I have a POCO class called Attachment that maps to a table in SqlServer
I have a form which contains listbox which will contains links of attachment when
I have a csv file as an attachment to the inbox. They should be
I have an FBO object with a color and depth attachment which I render
I have a pdf file attachment saved in the cloud. The file is attached
i have a situation where i need to send an email with attachment using
I have an entity called Attachment where it has a to-many relationship with no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.