Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A simple Spree extension allowing administrators to upload files and manage uploaded files

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 config
Octocat-spinner-32 db
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 vendor
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 file_store_extension.rb
Octocat-spinner-32 file_store_hooks.rb
README.markdown

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 1. For 0.9.x: git clone git://github.com/pklingem/spree-file-store.git -b 0.9.x vendor/extensions/file_store For 0.10.x: git clone git://github.com/pklingem/spree-file-store.git -b 0.10.x vendor/extensions/file_store
  2. 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

Something went wrong with that request. Please try again.