Skip to content

Latest commit

 

History

History
80 lines (56 loc) · 2.67 KB

README.markdown

File metadata and controls

80 lines (56 loc) · 2.67 KB

File Store

A simple Spree extension that places a tab in the Administration section allowing users to upload files and manage uploaded files. Uploaded files are placed within the public directory and are therefore readable by users of the application.

Installation

From the beginning:

  1. Make your spree website
  2. git clone vendor/extensions/file_store
  3. rake db:migrate

And you are ready to go! If you are using capistrano to deploy to your production server, don't forget to share the uploads dir over your releases. See example capistrano snippets at the bottom of this file.

Using The Links

If you want to add any link to a page in your website then the file upload page will give you a link like this:

http://localhost:3000/uploaded_files/0000/0002/Gaming.pdf

you should use it in your element like this:

/uploaded_files/0000/0002/Gaming.pdf

For example, if you wanted to make a link to this pdf:

<a href="/uploaded_files/0000/0002/Gaming.pdf">Gaming PDF</a>

Troubleshooting

If you are getting a 'Template is missing' error (Missing template admin/uploaded_files/index.erb in view path), then you are probably missing the haml gem. Two options:

  • Require the HAML gem in your environment.rb, or:
  • Use the 'erb' branch that you can find in Robert Massaioli's fork

Example capistrano setup

If you deploy using Capistrano, and don't like 404's, it is important that the 'public/uploaded_files' directory is a) excluded from your Version Control System and b) symlinked to an 'uploaded_files' in a shared dir. You will have to take care of the first thing yourself, and here is a capistrano snippet to set you up for the latter:


  namespace :uploads do
    desc "Create shared uploads dir"
    task :create\_shared\_uploads do
        run "mkdir -p #{shared\_path}/public/uploaded\_files"
    end

    desc "Link public/uploaded_files to shared/public/uploaded_files"
    task :link_uploads do
        run "ln -nfs #{shared_path}/public/uploaded_files #{release_path}/public/uploaded_files"
    end
  end

  after "deploy:setup" do
      uploads::create\_shared\_uploads
  end
  
  after "deploy:update_code" do
      uploads::link_uploads
  end

Contributors