Capistrano and uploads to the public directory


#1

I need some help. I (finally) have an app setup for capistrano
deployment. The only issue is that the admin interface allows uploads
of some file to the public directory.

When capistrano does a deploy, I get a brand new public directory,
wiping out all the uploaded files.

I am sure other have ran into this before, there must be a solution. I
thought about putting all the uploaded file in the same spot, but the
uploads have different purposes in multiple areas and would be awkward
to simply group them into some articficial “uploads” directory that gets
symlinked in.

Any ideas?


#2

Well, I recommend creating a directory called “uploads” in your “shared”
folder in your capistrano directory and uploading them there. If you
allow people to upload directly to your released app’s public directory,
then when you deploy a new revision, all those uploads will be archived.
If you instead upload them to the shared folder, you can use custom
routes to display them using send_file.

Because you said they have different purposes in multiple areas, I see
the format like this:

:area/:file

For a simple one. You can forward that route to a controller which will
then load the data from the shared folder, and use send_file to send it
directly to the browser, as if that file were really located at the
requsted URL.

Alex W. wrote:

I need some help. I (finally) have an app setup for capistrano
deployment. The only issue is that the admin interface allows uploads
of some file to the public directory.

When capistrano does a deploy, I get a brand new public directory,
wiping out all the uploaded files.

I am sure other have ran into this before, there must be a solution. I
thought about putting all the uploaded file in the same spot, but the
uploads have different purposes in multiple areas and would be awkward
to simply group them into some articficial “uploads” directory that gets
symlinked in.

Any ideas?