Symfony4 - good practice for storing uploaded files
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
add a comment |
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
add a comment |
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
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
git symfony upload
edited Nov 12 '18 at 11:47
cezar
5,61232454
5,61232454
asked Nov 11 '18 at 6:25
tonitotonito
206
206
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.
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
add a comment |
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 11 '18 at 10:00
ArneArne
834
834
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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