Change "file storage" for a specific "file" field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Firyo
    Senior Member
    • Jun 2022
    • 134

    Change "file storage" for a specific "file" field

    Hi there,

    I recently added multiples file storages "types" to my EspoCRM (following this post https://forum.espocrm.com/forum/deve...urgent-problem).
    Everyone of my "custom" file storages are just there to split the different upload files on my CRM (So It's like 'data/upload/something' for all of them).

    So I'm looking for a way to tell the CRM that if someone fill a file into a specific field into a specific entity, this file must be stored in the "Something" storage and not the default one.

    Kind regards,
    Firyo.
  • yuri
    Member
    • Mar 2014
    • 8483

    #2
    Hi,

    You can set 'storage' attribute for an attachment entity in a before-save hook.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • Firyo
      Senior Member
      • Jun 2022
      • 134

      #3
      Hi yuri,

      Okay, I've created an override for the "Attachement" repository class and called a function before the call of the function "processBeforeSaveNew".

      Now I wanted to know, is the "Attachment" entity meant to be linked to multiple entities ?
      I'm asking this because when I remove the link between one of them the Attachement itself is removed but still shown as linked in the other linked entities.

      Comment

      • Firyo
        Senior Member
        • Jun 2022
        • 134

        #4
        Ok, after some research I apears that an Attachment is meant to be linked to only one entity.

        Comment


        • yuri
          yuri commented
          Editing a comment
          Correct. Attachment record can be duplicated with its sourceId referring to the original to prevent necessity to duplicate an actual file.

        • Firyo
          Firyo commented
          Editing a comment
          Ok, in this case I'll edit my procedure that was using the same Attachment for multiple entities.
      Working...