Sha256: 6846774d9390af3ae6562c15508590862f83d82c53cd32b12dcdfb1571cc85ff

Contents?: true

Size: 480 Bytes

Versions: 6

Compression:

Stored size: 480 Bytes

Contents

require_relative "manage"

module Octodmin::Controllers::Posts
  class Upload < Manage
    include Octodmin::Action
    expose :upload

    def call(params)
      super

      site = Octodmin::Site.new
      file = params[:file]
      dir  = File.join(site.source, "octodmin", @post.identifier)
      path = File.join(dir, file["filename"])

      FileUtils.mkdir_p(dir)
      FileUtils.cp(file["tempfile"].path, path)

      @upload = path.sub(site.source, "")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
octodmin-0.3.5 app/controllers/posts/upload.rb
octodmin-0.3.4 app/controllers/posts/upload.rb
octodmin-0.3.3 app/controllers/posts/upload.rb
octodmin-0.3.2 app/controllers/posts/upload.rb
octodmin-0.3.1 app/controllers/posts/upload.rb
octodmin-0.3.0 app/controllers/posts/upload.rb