This commit is contained in:
Nicolas Bally 2016-12-19 00:21:01 +01:00
parent bc9e6945e7
commit 6792d2df62
4 changed files with 26 additions and 2 deletions

View File

@ -0,0 +1,14 @@
# -*- encoding : utf-8 -*-
class DownloadContactFilesController < ApplicationController
def index
end
def show
@data_file = ContactFile.find_by_token(params[:id])
send_file @data_file.file.path #, :disposition => "inline"
end
end

View File

@ -13,4 +13,14 @@ class ContactFile < ActiveRecord::Base
end
before_create { generate_token() }
def generate_token()
begin
self[:token] = SecureRandom.urlsafe_base64
end while ContactFile.exists?(:token => self[:token])
end
end

View File

@ -17,7 +17,7 @@ class ContactFileUploader < CarrierWave::Uploader::Base
end
def url
"/download_data_files/#{model.token}"
"/download_contact_files/#{model.token}"
end

View File

@ -168,7 +168,7 @@ CMSnb::Application.routes.draw do
resources :download_contact_files
resources :download_data_files