Symfony4 - good practice for storing uploaded files










0















In the web app I am developing, the client will upload a lot of little pictures (from a backend view) that will be shown in the user front end.



Currently, I store all the picture here:



backgrounds_directory: '%kernel.project_dir%/public/uploads/backgrounds'
decorations_directory: '%kernel.project_dir%/public/uploads/decorations'
templates_directory: '%kernel.project_dir%/public/uploads/templates'


So they are actually in the S4 project. As I version my project with GIT, those upload will not be synced with my dev version.



What would be the best practice?



  • Store them somewhere out of S4 project and cronjob a GIT commit every hour?

  • Store the picture out of symfony like on an amazon S3 server and only store only the ID of the picture in my DB to retreive it later on?

  • GIT ignore this repository and back it up regularly?

  • Save a base64 of the picture in my DB?

I'm not really sure what track to choose. I guess there is a lot of choices. If you have experience with that, I'd like to take some advices.










share|improve this question




























    0















    In the web app I am developing, the client will upload a lot of little pictures (from a backend view) that will be shown in the user front end.



    Currently, I store all the picture here:



    backgrounds_directory: '%kernel.project_dir%/public/uploads/backgrounds'
    decorations_directory: '%kernel.project_dir%/public/uploads/decorations'
    templates_directory: '%kernel.project_dir%/public/uploads/templates'


    So they are actually in the S4 project. As I version my project with GIT, those upload will not be synced with my dev version.



    What would be the best practice?



    • Store them somewhere out of S4 project and cronjob a GIT commit every hour?

    • Store the picture out of symfony like on an amazon S3 server and only store only the ID of the picture in my DB to retreive it later on?

    • GIT ignore this repository and back it up regularly?

    • Save a base64 of the picture in my DB?

    I'm not really sure what track to choose. I guess there is a lot of choices. If you have experience with that, I'd like to take some advices.










    share|improve this question


























      0












      0








      0








      In the web app I am developing, the client will upload a lot of little pictures (from a backend view) that will be shown in the user front end.



      Currently, I store all the picture here:



      backgrounds_directory: '%kernel.project_dir%/public/uploads/backgrounds'
      decorations_directory: '%kernel.project_dir%/public/uploads/decorations'
      templates_directory: '%kernel.project_dir%/public/uploads/templates'


      So they are actually in the S4 project. As I version my project with GIT, those upload will not be synced with my dev version.



      What would be the best practice?



      • Store them somewhere out of S4 project and cronjob a GIT commit every hour?

      • Store the picture out of symfony like on an amazon S3 server and only store only the ID of the picture in my DB to retreive it later on?

      • GIT ignore this repository and back it up regularly?

      • Save a base64 of the picture in my DB?

      I'm not really sure what track to choose. I guess there is a lot of choices. If you have experience with that, I'd like to take some advices.










      share|improve this question
















      In the web app I am developing, the client will upload a lot of little pictures (from a backend view) that will be shown in the user front end.



      Currently, I store all the picture here:



      backgrounds_directory: '%kernel.project_dir%/public/uploads/backgrounds'
      decorations_directory: '%kernel.project_dir%/public/uploads/decorations'
      templates_directory: '%kernel.project_dir%/public/uploads/templates'


      So they are actually in the S4 project. As I version my project with GIT, those upload will not be synced with my dev version.



      What would be the best practice?



      • Store them somewhere out of S4 project and cronjob a GIT commit every hour?

      • Store the picture out of symfony like on an amazon S3 server and only store only the ID of the picture in my DB to retreive it later on?

      • GIT ignore this repository and back it up regularly?

      • Save a base64 of the picture in my DB?

      I'm not really sure what track to choose. I guess there is a lot of choices. If you have experience with that, I'd like to take some advices.







      git symfony upload






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 '18 at 11:47









      cezar

      5,61232454




      5,61232454










      asked Nov 11 '18 at 6:25









      tonitotonito

      206




      206






















          2 Answers
          2






          active

          oldest

          votes


















          0














          Mostly depends on your needs and requirments form your application. I will describe solution I'm using.



          First I'm abstracting filesystem operations using FlySystem, which allows to easily change between S3, local filesystem or whatever (in my configuration I have in dev environment mapped to local filesystem and production usually to S3).



          Folder for uploads should be for sure ignored in git. Git is good for storing more textual information, with images not so good at tracking changes etc.



          You still need to make backup solution (we backup S3 content to different bucket as well) in case of error in application / attack whatever.



          Comment to database solution: This could be way to go, but really depends on your needs and your choice of database. But definitely don't use base64, but usually databases has something like BLOB/Binary datatype which is much better choice for that.






          share|improve this answer























          • Thanks, so I could keep uploading to my Symfony folder, ignored by git, as it won't need any further development ? I will only need to back up those file from time to time, with like a S3 bucket ?

            – tonito
            Nov 11 '18 at 9:33












          • Yeah, I consider images as runtime data, which needs to be backed up (same as database, etc).

            – M. Kebza
            Nov 11 '18 at 9:46


















          0














          since it is user data which probably also depends on the database, I would not add the pcitures to your development Git repository. The Git repository should be for the source code of your application, not for user data.



          Where to upload also depends on your requirements. The easiest way is how you do it at the moment, storing the files locally on the webserver where your application runs. This would only be a problem if you have more files than hosting storage or you run your application on several servers. In such cases it would make sense to store them on an external service, for example Amazon S3. But of course this will make things a little more complicated (external service, costs, integration, etc.)



          If you need to sync your development environment from time to time with the production version, you could use rsync to copy new or changed files to your environment. This of course does not replace a proper backup, which should be setup directly on the production server and also include the database.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246374%2fsymfony4-good-practice-for-storing-uploaded-files%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Mostly depends on your needs and requirments form your application. I will describe solution I'm using.



            First I'm abstracting filesystem operations using FlySystem, which allows to easily change between S3, local filesystem or whatever (in my configuration I have in dev environment mapped to local filesystem and production usually to S3).



            Folder for uploads should be for sure ignored in git. Git is good for storing more textual information, with images not so good at tracking changes etc.



            You still need to make backup solution (we backup S3 content to different bucket as well) in case of error in application / attack whatever.



            Comment to database solution: This could be way to go, but really depends on your needs and your choice of database. But definitely don't use base64, but usually databases has something like BLOB/Binary datatype which is much better choice for that.






            share|improve this answer























            • Thanks, so I could keep uploading to my Symfony folder, ignored by git, as it won't need any further development ? I will only need to back up those file from time to time, with like a S3 bucket ?

              – tonito
              Nov 11 '18 at 9:33












            • Yeah, I consider images as runtime data, which needs to be backed up (same as database, etc).

              – M. Kebza
              Nov 11 '18 at 9:46















            0














            Mostly depends on your needs and requirments form your application. I will describe solution I'm using.



            First I'm abstracting filesystem operations using FlySystem, which allows to easily change between S3, local filesystem or whatever (in my configuration I have in dev environment mapped to local filesystem and production usually to S3).



            Folder for uploads should be for sure ignored in git. Git is good for storing more textual information, with images not so good at tracking changes etc.



            You still need to make backup solution (we backup S3 content to different bucket as well) in case of error in application / attack whatever.



            Comment to database solution: This could be way to go, but really depends on your needs and your choice of database. But definitely don't use base64, but usually databases has something like BLOB/Binary datatype which is much better choice for that.






            share|improve this answer























            • Thanks, so I could keep uploading to my Symfony folder, ignored by git, as it won't need any further development ? I will only need to back up those file from time to time, with like a S3 bucket ?

              – tonito
              Nov 11 '18 at 9:33












            • Yeah, I consider images as runtime data, which needs to be backed up (same as database, etc).

              – M. Kebza
              Nov 11 '18 at 9:46













            0












            0








            0







            Mostly depends on your needs and requirments form your application. I will describe solution I'm using.



            First I'm abstracting filesystem operations using FlySystem, which allows to easily change between S3, local filesystem or whatever (in my configuration I have in dev environment mapped to local filesystem and production usually to S3).



            Folder for uploads should be for sure ignored in git. Git is good for storing more textual information, with images not so good at tracking changes etc.



            You still need to make backup solution (we backup S3 content to different bucket as well) in case of error in application / attack whatever.



            Comment to database solution: This could be way to go, but really depends on your needs and your choice of database. But definitely don't use base64, but usually databases has something like BLOB/Binary datatype which is much better choice for that.






            share|improve this answer













            Mostly depends on your needs and requirments form your application. I will describe solution I'm using.



            First I'm abstracting filesystem operations using FlySystem, which allows to easily change between S3, local filesystem or whatever (in my configuration I have in dev environment mapped to local filesystem and production usually to S3).



            Folder for uploads should be for sure ignored in git. Git is good for storing more textual information, with images not so good at tracking changes etc.



            You still need to make backup solution (we backup S3 content to different bucket as well) in case of error in application / attack whatever.



            Comment to database solution: This could be way to go, but really depends on your needs and your choice of database. But definitely don't use base64, but usually databases has something like BLOB/Binary datatype which is much better choice for that.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 11 '18 at 7:09









            M. KebzaM. Kebza

            1,157512




            1,157512












            • Thanks, so I could keep uploading to my Symfony folder, ignored by git, as it won't need any further development ? I will only need to back up those file from time to time, with like a S3 bucket ?

              – tonito
              Nov 11 '18 at 9:33












            • Yeah, I consider images as runtime data, which needs to be backed up (same as database, etc).

              – M. Kebza
              Nov 11 '18 at 9:46

















            • Thanks, so I could keep uploading to my Symfony folder, ignored by git, as it won't need any further development ? I will only need to back up those file from time to time, with like a S3 bucket ?

              – tonito
              Nov 11 '18 at 9:33












            • Yeah, I consider images as runtime data, which needs to be backed up (same as database, etc).

              – M. Kebza
              Nov 11 '18 at 9:46
















            Thanks, so I could keep uploading to my Symfony folder, ignored by git, as it won't need any further development ? I will only need to back up those file from time to time, with like a S3 bucket ?

            – tonito
            Nov 11 '18 at 9:33






            Thanks, so I could keep uploading to my Symfony folder, ignored by git, as it won't need any further development ? I will only need to back up those file from time to time, with like a S3 bucket ?

            – tonito
            Nov 11 '18 at 9:33














            Yeah, I consider images as runtime data, which needs to be backed up (same as database, etc).

            – M. Kebza
            Nov 11 '18 at 9:46





            Yeah, I consider images as runtime data, which needs to be backed up (same as database, etc).

            – M. Kebza
            Nov 11 '18 at 9:46













            0














            since it is user data which probably also depends on the database, I would not add the pcitures to your development Git repository. The Git repository should be for the source code of your application, not for user data.



            Where to upload also depends on your requirements. The easiest way is how you do it at the moment, storing the files locally on the webserver where your application runs. This would only be a problem if you have more files than hosting storage or you run your application on several servers. In such cases it would make sense to store them on an external service, for example Amazon S3. But of course this will make things a little more complicated (external service, costs, integration, etc.)



            If you need to sync your development environment from time to time with the production version, you could use rsync to copy new or changed files to your environment. This of course does not replace a proper backup, which should be setup directly on the production server and also include the database.






            share|improve this answer



























              0














              since it is user data which probably also depends on the database, I would not add the pcitures to your development Git repository. The Git repository should be for the source code of your application, not for user data.



              Where to upload also depends on your requirements. The easiest way is how you do it at the moment, storing the files locally on the webserver where your application runs. This would only be a problem if you have more files than hosting storage or you run your application on several servers. In such cases it would make sense to store them on an external service, for example Amazon S3. But of course this will make things a little more complicated (external service, costs, integration, etc.)



              If you need to sync your development environment from time to time with the production version, you could use rsync to copy new or changed files to your environment. This of course does not replace a proper backup, which should be setup directly on the production server and also include the database.






              share|improve this answer

























                0












                0








                0







                since it is user data which probably also depends on the database, I would not add the pcitures to your development Git repository. The Git repository should be for the source code of your application, not for user data.



                Where to upload also depends on your requirements. The easiest way is how you do it at the moment, storing the files locally on the webserver where your application runs. This would only be a problem if you have more files than hosting storage or you run your application on several servers. In such cases it would make sense to store them on an external service, for example Amazon S3. But of course this will make things a little more complicated (external service, costs, integration, etc.)



                If you need to sync your development environment from time to time with the production version, you could use rsync to copy new or changed files to your environment. This of course does not replace a proper backup, which should be setup directly on the production server and also include the database.






                share|improve this answer













                since it is user data which probably also depends on the database, I would not add the pcitures to your development Git repository. The Git repository should be for the source code of your application, not for user data.



                Where to upload also depends on your requirements. The easiest way is how you do it at the moment, storing the files locally on the webserver where your application runs. This would only be a problem if you have more files than hosting storage or you run your application on several servers. In such cases it would make sense to store them on an external service, for example Amazon S3. But of course this will make things a little more complicated (external service, costs, integration, etc.)



                If you need to sync your development environment from time to time with the production version, you could use rsync to copy new or changed files to your environment. This of course does not replace a proper backup, which should be setup directly on the production server and also include the database.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 11 '18 at 10:00









                ArneArne

                834




                834



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246374%2fsymfony4-good-practice-for-storing-uploaded-files%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                    Crossroads (UK TV series)

                    ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế