Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFilePart.java')
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFilePart.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFilePart.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFilePart.java
new file mode 100644
index 000000000..9a0895dce
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaFilePart.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.bugzilla.core;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.util.EncodingUtil;
+import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentSource;
+import org.eclipse.mylyn.tasks.core.data.TaskAttachmentPartSource;
+
+public class BugzillaFilePart extends FilePart {
+
+ private final String filename;
+
+ public BugzillaFilePart(AbstractTaskAttachmentSource source, String filename, String contentType, String charset) {
+ super(IBugzillaConstants.POST_INPUT_DATA, new TaskAttachmentPartSource(source, null), contentType, charset);
+ this.filename = filename;
+ }
+
+ @Override
+ protected void sendDispositionHeader(OutputStream out) throws IOException {
+ super.sendDispositionHeader(out);
+ if (filename != null) {
+ out.write(EncodingUtil.getAsciiBytes(FILE_NAME));
+ out.write(QUOTE_BYTES);
+ out.write(EncodingUtil.getBytes(filename, getCharSet()));
+ out.write(QUOTE_BYTES);
+ }
+ }
+}

Back to the top