lib/mms2r/media.rb
def process_media(part)
      # Mail body auto-magically decodes quoted
      # printable for text/html type.
      file = temp_file(part)
      if part.part_type? =~ /^text\// ||
         part.part_type? == 'application/smil'
        type, content = transform_text_part(part)
      else
        if part.part_type? == 'application/octet-stream'
          type = type_from_filename(filename?(part))
        else
          type = part.part_type?
        end
        content = part.body.decoded
      end
      return type, nil if content.nil? || content.empty?

      log("#{self.class} writing file #{file}", :info)
      File.open(file, 'wb'){ |f| f.write(content) }
      return type, file
    end
def process_media(part)
      # Mail body auto-magically decodes quoted
      # printable for text/html type.
      file = temp_file(part)
      if part.part_type? =~ /^text\// ||
         part.part_type? == 'application/smil'
        type, content = transform_text_part(part)
      else
        if part.part_type? == 'application/octet-stream'
          type = type_from_filename(filename?(part))
        else
          type = part.part_type?
        end
        content = part.body.decoded
      end
      return type, nil if content.nil? || content.empty?

      log("#{self.class} writing file #{file}", :info)
      File.open(file, 'wb'){ |f| f.write(content) }
      return type, file
    end
Helper for process template method to decode the part based on its type
 and write its content to a temporary file.  Returns path to temporary
 file that holds the content.  Parts with a main type of text will have
 their contents transformed with a call to transform_text

 Producers should only override this method if the parts of the MMS need
 special treatment besides what is expected for a normal mime part (like
 Sprint).

 Returns a tuple of content type, file path