lib/ribose/file_uploader.rb in ribose-0.3.2 vs lib/ribose/file_uploader.rb in ribose-0.4.0

- old
+ new

@@ -49,11 +49,13 @@ end end def notify_ribose_file_upload_endpoint(response, key) if response.status.to_i == 200 - content = Request.post(space_file_path, file_attributes.merge(key: key)) + attributes = notifiable_attributes(file_attributes, key) + + content = Request.post(space_file_path, attributes) content.is_a?(Sawyer::Resource) ? content : parse_to_ribose_os(content) end end def faraday_file_io @@ -68,14 +70,19 @@ @file_content_type ||= content_type_form_file end def content_type_form_file require "mime/types" - MIME::Types.type_for(file.path).first.content_type + mime = MIME::Types.type_for(file.path).first + mime ? mime.content_type : "application/octet-stream" end def parse_to_ribose_os(content) JSON.parse(content, object_class: Ribose::OpenStruct) + end + + def notifiable_attributes(attributes, key) + attributes.merge(key: key) end def file_attributes @file_attributes ||= { filesize: file.size,