Sha256: 8ee162ef9f987a3a2c07039f139d5ab66c1dc68b0effcb5a72bc61d7bbc97a59

Contents?: true

Size: 856 Bytes

Versions: 3

Compression:

Stored size: 856 Bytes

Contents

module TypeStation
  class FileController < TypeStation::ApplicationController

    IMAGE_FORMATS = ['jpg', 'jpe', 'jpeg', 'jpc', 'jp2', 'j2k', 'wdp', 'jxr', 'hdp', 'png', 'gif', 'gif', 'webp', 'webp', 'bmp', 'tif', 'tiff', 'ico', 'pdf', 'ps', 'ept', 'eps', 'eps3', 'psd', 'svg', 'ai', 'djvu', 'flif', 'tga']

    def download
      redirect_to private_download_url
    end

    private

    def private_download_url
      if IMAGE_FORMATS.include?(params[:format].downcase)
        Cloudinary::Utils.private_download_url(params[:identifier], params[:format], resource_type: :image, attachment: true, expires_at: 1.minute.from_now)
      else
        Cloudinary::Utils.private_download_url([params[:identifier], params[:format]].join('.'), params[:format], resource_type: :raw, attachment: true, expires_at: 1.minute.from_now)
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
type_station-0.7.0 app/controllers/type_station/file_controller.rb
type_station-0.6.0 app/controllers/type_station/file_controller.rb
type_station-0.5.4 app/controllers/type_station/file_controller.rb