lib/nylas/utils/file_utils.rb in nylas-6.0.0.beta.3 vs lib/nylas/utils/file_utils.rb in nylas-6.0.0.beta.4

- old
+ new

@@ -36,11 +36,15 @@ # Build the request to attach a file to a message/draft object. # @param file_path [String] The path to the file to attach. # @return [Hash] The request that will attach the file to the message/draft def self.attach_file_request_builder(file_path) filename = File.basename(file_path) - content_type = MIME::Types.type_for(file_path).first.to_s - content_type = "application/octet-stream" if content_type.empty? + content_type = MIME::Types.type_for(file_path) + content_type = if !content_type.nil? && !content_type.empty? + content_type.first.to_s + else + "application/octet-stream" + end size = File.size(file_path) content = File.new(file_path, "rb") { filename: filename,