Module: Nylas::FileUtils
- Defined in:
- lib/nylas/utils/file_utils.rb
Overview
A collection of file-related utilities.
Class Method Summary collapse
-
.attach_file_request_builder(file_path) ⇒ Hash
Build the request to attach a file to a message/draft object.
Class Method Details
.attach_file_request_builder(file_path) ⇒ Hash
Build the request to attach a file to a message/draft object.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nylas/utils/file_utils.rb', line 34 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? size = File.size(file_path) content = File.new(file_path, "rb") { filename: filename, content_type: content_type, size: size, content: content } end |