class Api::DocumentsController < ApiController

  def download    
    document = Document.find params[:id]
    redirect_to ("http://transparencia.gob.sv/institutions/#{document.institution.id}/documents/#{document.id}/download"), :status => 301
    #if Document.exists? params[:id]
    
      #document = Document.find params[:id]
      #document.update_column(:downloads, (document.downloads + 1))
      #send_file document.datafile.path,
                #filename: [document.name, File.extname(document.datafile.path)].join,
                #type: document.datafile_content_type,
                #disposition: 'attachment'
    #else
      #render_404
    #end
  end

end
