Creates a body part for an attachment that is downloaded by the user.
@throws IOException
345653
public static MimeBodyPart newAttachmentBodyPart( String content, String contentId, String mimeType, String fileName)
    throws MessagingException, IOException
  {
    MimeBodyPart mimeBodyPart = new MimeBodyPart();
//    log.debug("Creating an attachment for content '{}', mimeType '{}', fileName '{}'.", new Object[] {content, mimeType, fileName});
    mimeBodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(content, mimeType + UTF_8_CHARACTER_SET)));
    if( contentId != null ) {
      mimeBodyPart.setHeader("Content-ID", contentId);
    }
    mimeBodyPart.setDisposition(DISPOSITION_ATTACHMENT);
    if( fileName != null ) {
      mimeBodyPart.setFileName(fileName);
    }
    return mimeBodyPart;
  }
355247
public void addFilePart(final String fieldName, final URL urlToUploadFile)
        throws IOException
    {
        //
        // Maybe try and extract a filename from the last part of the url?
        // Or have the user pass it in?
        // Or just leave it blank as I have already done?
        //
        addFilePart(fieldName,
                    urlToUploadFile.openStream(),
                    null,
                    URLConnection.guessContentTypeFromName(urlToUploadFile.toString()));
    }
644571
def _create_related_attachment(self, filename, content, mimetype=None):
        
        attachment = super(EmailMultiRelated, self)._create_attachment(filename, content, mimetype)
        if filename:
            mimetype = attachment['Content-Type']
            del(attachment['Content-Type'])
            del(attachment['Content-Disposition'])
            attachment.add_header('Content-Disposition', 'inline', filename=filename)
            attachment.add_header('Content-Type', mimetype, name=filename)
            attachment.add_header('Content-ID', '<%s>' % filename)
        return attachment
661381
public function addAttachmentPart($resource, $mimeType, $filename = null, $disposition = 'attachment')
    {
        $this->messageHelperService
            ->getMultipartHelper()
            ->createAndAddPartForAttachment($this, $resource, $mimeType, $disposition, $filename);
    }
276416
protected void generatePackageUseFile() throws IOException {
        HtmlTree body = getPackageUseHeader();
        HtmlTree div = new HtmlTree(HtmlTag.DIV);
        div.addStyle(HtmlStyle.contentContainer);
        if (usingPackageToUsedClasses.isEmpty()) {
            div.addContent(getResource(
                    "doclet.ClassUse_No.usage.of.0", pkgdoc.name()));
        } else {
            addPackageUse(div);
        }
        if (configuration.allowTag(HtmlTag.MAIN)) {
            mainTree.addContent(div);
            body.addContent(mainTree);
        } else {
            body.addContent(div);
        }
        HtmlTree tree = (configuration.allowTag(HtmlTag.FOOTER))
                ? HtmlTree.FOOTER()
                : body;
        addNavLinks(false, tree);
        addBottom(tree);
        if (configuration.allowTag(HtmlTag.FOOTER)) {
            body.addContent(tree);
        }
        printHtmlDocument(null, true, body);
    }
236639
public OkRequest<T> part(final String name, final String filename,
                             final String contentType, final String part) throws IOException {

        startPart();
        writePartHeader(name, filename, contentType);
        mOutput.write(part);

        return this;
    }
789635
public static MimeBodyPart newHtmlAttachmentBodyPart( URL contentUrl, String contentId )
    throws MessagingException
  {
    MimeBodyPart mimeBodyPart = new MimeBodyPart();
    mimeBodyPart.setDataHandler(new DataHandler(contentUrl));
    if( contentId != null ) {
      mimeBodyPart.setHeader("Content-ID", contentId);
    }
    return mimeBodyPart;
  }
511390
public static Attachment create(@NonNull String data, @NonNull String type, @Nullable String folder, @Nullable String name) {
        return new Attachment(ContentData.create(data, type, name), folder, type);
    }
186558
private Part createErrorPart(Attachment a) {
        return Part.builder().setName(String.valueOf(a.hashCode())).setSize(0).setType(Attachment.LOCAL_PART_TYPE_ERROR).setUrl(null).setData(a.getError().getLocalizedMessage()).build();
    }
1127934
public OkRequest<T> part(final String name, final String filename,
                             final String contentType, final File part) throws IOException {
        final InputStream stream;
        stream = new BufferedInputStream(new FileInputStream(part));
//            incrementTotalSize(part.length());

        return part(name, filename, contentType, stream);
    }
208326
function (attachment) {
                    // Define custom metadata properties for the file before saving
                    var customFileMetadata = {};
                    var parentItemId = model.getParentItemId();
                    if (parentItemId && parentItemId != '') customFileMetadata[scope.attachmentFilterFieldName + "Id"] = String(parentItemId);

                    // Upload the file using the SharePoint item service
                    return spFormFactory.uploadFileToDocLib(attachment.File.ArrayBuffer, scope.attachmentDocLibName, scope.attachmentDocFolderName, attachment.File.Name, attachment.File.Title, customFileMetadata);
                }
109179
function Attachment(options) {
    this.fileName = options.fileName;
    this.contents = options.contents;
    this.filePath = options.filePath;
    this.streamSource = options.streamSource;
    this.contentType = options.contentType;
    this.cid = options.cid;
}
609730
protected BodyPart handleBinaryPart(MimePart mediaPart, String contentType) throws IOException, MessagingException {
        String contentId = mediaPart.getContentID() != null ? "(" + mediaPart.getContentID() + ")" : "";
        return new BodyPart(mediaPart.getFileName() + contentId, contentType);
    }
695565
public void addPart(AttachmentPart part) {
        if (attachments == null) {
            attachments = new BodyPart.Attachments();
        }

        this.attachments.add(part);
    }
1162029
private void attachFormDataBody(final HttpServerExchange exchange) throws IOException {
        Object data;
        FormParserFactory formParserFactory = FormParserFactory.builder().build();
        FormDataParser parser = formParserFactory.createParser(exchange);
        if (parser != null) {
            FormData formData = parser.parseBlocking();
            data = BodyConverter.convert(formData);
            exchange.putAttachment(REQUEST_BODY, data);
        }
    }
969662
public static OAuthRequest attachFile(File file, OAuthRequest request) throws IOException {
        String boundary = generateBoundaryString();
        request.addHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
        request.addBodyParameter("file", file.getName());

        StringBuilder boundaryMessage = new StringBuilder("--");
        boundaryMessage.append(boundary)
                .append("\r\n")
                .append("Content-Disposition: form-data; name=\"file\"; filename=\"").append(file.getName())
                .append("\"\r\n")
                .append("Content-Type: ").append("application/x-unknown")
                .append("\r\n\r\n");

        String endBoundary = "\r\n--" + boundary + "--\r\n";

        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        buffer.write(boundaryMessage.toString().getBytes(CHARSET_NAME));
        buffer.write(Files.readFile(file));
        buffer.write(endBoundary.getBytes(CHARSET_NAME));
        request.addPayload(buffer.toByteArray());
        buffer.close();

        return request;
    }
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) . '--';
    }