returns mime part that constitutes this attachment
552613
def get_mime_representation(self):
        """"""
        part = deepcopy(self.part)
        part.set_param('maxlinelen', '78', header='Content-Disposition')
        return part
913792
def attachment(filename = nil, disposition = :attachment)
      response['Content-Disposition'] = disposition.to_s.dup
      if filename
        params = '; filename="%s"' % File.basename(filename)
        response['Content-Disposition'] << params
        ext = File.extname(filename)
        content_type(ext) unless response['Content-Type'] or ext.empty?
      end
    end
41794
def find_attachment
      content_type_name = header[:content_type].filename rescue nil
      content_disp_name = header[:content_disposition].filename rescue nil
      content_loc_name = header[:content_location].location rescue nil

      if content_type && content_type_name
        filename = content_type_name
      elsif content_disposition && content_disp_name
        filename = content_disp_name
      elsif content_location && content_loc_name
        filename = content_loc_name
      elsif self.mime_type == "message/rfc822"
        filename = "#{rand(100000000)}.eml"
      else
        filename = nil
      end

      if filename
        # Normal decode
        filename = Mail::Encodings.decode_encode(filename, :decode) rescue filename
      end
      filename
    end
1129600
def _get_attachment_data(self, id, filename):
        
        uri = '/'.join([self.base_url, self.name, id, 'Attachments', filename])
        return uri, {}, 'get', None, None, False
973120
function getMime(path) {
          var index = String(path).lastIndexOf(".");
          if (index < 0) {
              return defaultMime;
          }
          var type = exports.mime.types[path.substring(index).toLowerCase()] || defaultMime;
          return (/(text|javascript)/).test(type)
            ? type + "; charset=utf-8"
            : type;
      }
1330301
protected function locateAttachedMedia() {

		// Gets media attached to the post by mime type.
		$attached_media = get_attached_media( $this->type, $this->post_id );

		// If media is found.
		if ( $attached_media ) {

			// Get the first attachment/post object found for the post.
			$post = array_shift( $attached_media );

			// Gets the URI for the attachment (the media file).
			$url = esc_url( wp_get_attachment_url( $post->ID ) );

			// Run the media as a shortcode using WordPress' built-in
			// [audio] and [video] shortcodes.
			if ( in_array( $this->type, [ 'audio', 'video' ] ) ) {

				return call_user_func( "wp_{$this->type}_shortcode", [ 'src' => $url ] );
			}
		}

		return '';
	}
420736
def get_content_type(self):
        """"""
        ctype = self.part.get_content_type()
        # replace underspecified mime description by a better guess
        if ctype in ['octet/stream', 'application/octet-stream',
                     'application/octetstream']:
            ctype = guess_mimetype(self.get_data())
        return ctype
56865
def mime(self):
        """"""

        mimes = []
        for Kind in type(self).__mro__:
            for mime in getattr(Kind, '_mimes', []):
                if mime not in mimes:
                    mimes.append(mime)
        return mimes
724308
def get_attachment(self, file_path):
        ''''''

        try:
            file_ = open(file_path, 'rb')
            attachment = MIMEBase('application', 'octet-stream')
            attachment.set_payload(file_.read())
            file_.close()
            encoders.encode_base64(attachment)

            attachment.add_header('Content-Disposition', 'attachment',
                                  filename=os.path.basename(file_path))
            return attachment
        except IOError:
            traceback.print_exc()
            message = ('The requested file could not be read. Maybe wrong '
                       'permissions?')
            print >> sys.stderr, message
            sys.exit(6)
347121
private byte[] getImageContent(InputStream in, String mime) throws FMSException {
		byte[] imageInByte = null;
		ByteArrayOutputStream baos = null;
		try {
			BufferedImage originalImage = ImageIO.read(in);
			baos = new ByteArrayOutputStream();
			ImageIO.write(originalImage, mime, baos);
			baos.flush();
			imageInByte = baos.toByteArray();
			baos.close();
		} catch (IOException e) {
			throw new FMSException("Error while reading the upload file.", e);
		} finally {
			close(baos);
			close(in);
		}
		return imageInByte;
	}
1135554
public function getMime()
    {
      if (!$this->mime) {
        $this->mime = $this->getImageMime($this->_files['tmp_name']);
      }

      return $this->mime;
    }
867219
function getAttachment(binaryKey) {
    // console.log('Adding binary attachment', binaryKey);
    const index = attachments.findIndex((att) => (att.key === binaryKey));
    if (index !== -1) {
      const result = attachments[index].data;
      // TODO if attachment is sent mulitple times, we shouldn't remove it yet.
      attachments.splice(index, 1);
      return result;
    }
    console.error('Binary attachment key found without matching attachment');
    return null;
  }
203833
public function assembleAttachmentBody()
    {
        $body = array();
        $body[] = "This is a multi-part message in MIME format.";
        $body[] = "--{$this->_uid}";
        $body[] = "Content-Type: text/html; charset=\"utf-8\"";
        $body[] = "Content-Transfer-Encoding: quoted-printable";
        $body[] = "";
        $body[] = quoted_printable_encode($this->_message);
        $body[] = "";
        $body[] = "--{$this->_uid}";

        foreach ($this->_attachments as $attachment) {
            $body[] = $this->getAttachmentMimeTemplate($attachment);
        }

        return implode(PHP_EOL, $body) . '--';
    }
904835
def mime(self):
        '''
        
        '''
        return self.metadata['ContentType'] if 'ContentType' in self.metadata else BaseEngine.get_mimetype(self.buffer)
851381
def parts(self):
        
        parts = self.split(os.path.sep)
        parts[0] = parts[0] and parts[0] or '/'
        return parts
655730
function part_body($p)
    {
        // encrypted attachment, see parse_plain_encrypted()
        if ($p['part']->need_decryption && $p['part']->body === null) {
            $this->load_pgp_driver();

            $storage = $this->rc->get_storage();
            $body    = $storage->get_message_part($p['object']->uid, $p['part']->mime_id, $p['part'], null, null, true, 0, false);
            $result  = $this->pgp_decrypt($body);

            // @TODO: what to do on error?
            if ($result === true) {
                $p['part']->body = $body;
                $p['part']->size = strlen($body);
                $p['part']->body_modified = true;
            }
        }

        return $p;
    }
974272
def _get_attachments(self, id):
        """"""
        uri = '/'.join([self.base_url, self.name, id, 'Attachments']) + '/'
        return uri, {}, 'get', None, None, False