diff --git a/app/actions/media/create.rb b/app/actions/media/create.rb index 2fef994..66c8806 100644 --- a/app/actions/media/create.rb +++ b/app/actions/media/create.rb @@ -17,6 +17,7 @@ module Adamantium end m.success do |v| + logger.info("I have CREATED") res.status = 201 res.headers["Location"] = v res.body = { diff --git a/app/commands/media/upload.rb b/app/commands/media/upload.rb index f117dd9..f68471d 100644 --- a/app/commands/media/upload.rb +++ b/app/commands/media/upload.rb @@ -6,7 +6,7 @@ module Adamantium module Commands module Media class Upload < Command - include Deps["settings"] + include Deps["settings", "logger"] def call(file:) pathname = Time.now.strftime("%m-%Y") @@ -14,6 +14,8 @@ module Adamantium filename = "#{SecureRandom.uuid}#{File.extname(file[:filename])}" dirname = File.join("public", "media", pathname) + logger.info(dirname) + logger.info(File.directory?(dirname)) unless File.directory?(dirname) FileUtils.mkdir_p(dirname) @@ -21,11 +23,14 @@ module Adamantium begin File.write(File.join(dirname, filename), file[:tempfile].read) + logger.info("I WROTE") rescue Errno::ENOENT, NoMethodError => e + logger.info("I FAILED to write - #{e}") return Failure(e.message) end upload_path = File.join(settings.micropub_site_url, "/media/", "/#{pathname}/", filename).to_s + logger.info(upload_path) Success(upload_path) end end