Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

537 B
Raw Blame
# frozen_string_literal: true

class UploadedFile
  attr_reader :pathname

  def initialize(pathname)
    @pathname = pathname
  end

  def path
    pathname.to_s
  end

  def to_s
    path
  end

  def basename
    File.basename(path)
  end

  def self.load_from(path)
    full_path = Rails.root.join(path)
    shared_path = DownloadList::SHARED_PATH.join(File.basename(full_path))
    # with remote drivers, files to upload must be in the shared downloads folder
    FileUtils.cp(full_path, shared_path)
    new(shared_path)
  end
end