class Compostr::ImageUpload
Attributes
file_path[RW]
post_id[RW]
Public Class Methods
new(file_path, post_id=nil)
click to toggle source
# File lib/compostr/image_upload.rb, line 7 def initialize file_path, post_id=nil # TODO decide on getMediaLibrary to find an already uploaded image @file_path = file_path @post_id = post_id end
Public Instance Methods
do_upload!()
click to toggle source
Push data to Wordpress instance, return attachment_id
# File lib/compostr/image_upload.rb, line 14 def do_upload! data = create_data response = Compostr::wp.uploadFile(data: data) response["attachment_id"] end
Private Instance Methods
create_data()
click to toggle source
# File lib/compostr/image_upload.rb, line 22 def create_data { name: File.basename(@file_path), type: MIME::Types.type_for(file_path).first.to_s, post_id: @post_id || '', bits: XMLRPC::Base64.new(IO.read file_path) } end