Initial commit

This commit is contained in:
2023-01-27 22:55:09 +11:00
commit 833f3ea8b2
130 changed files with 5637 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
# frozen_string_literal: true
module Adamantium
module Commands
module Media
class Upload < Command
include Deps["settings"]
def call(file:)
pathname = Time.now.strftime("%m-%Y")
filename = file[:filename].split("/").last
dirname = File.join("public", "media", pathname)
unless File.directory?(dirname)
FileUtils.mkdir_p(dirname)
end
begin
File.write(File.join(dirname, filename), file[:tempfile].read)
rescue Errno::ENOENT, NoMethodError => e
return Failure(e.message)
end
upload_path = File.join(settings.micropub_site_url, "/media/", "/#{pathname}/", filename).to_s
Success(upload_path)
end
end
end
end
end