|
20 | 20 |
|
21 | 21 | import java.io.InputStream; |
22 | 22 | import java.io.File; |
| 23 | +import java.io.FileInputStream; |
| 24 | +import java.io.FileNotFoundException; |
23 | 25 | import java.io.UnsupportedEncodingException; |
24 | 26 | import java.util.LinkedList; |
25 | 27 | import java.util.List; |
@@ -89,30 +91,39 @@ public void put(String key, String value){ |
89 | 91 | * @param key the key name for the new param. |
90 | 92 | * @param filedata the file contents to add. |
91 | 93 | */ |
92 | | - public void put(String key, InputStream filedata) { |
93 | | - put(key, filedata, null, null); |
| 94 | + public void put(String key, File file) throws FileNotFoundException { |
| 95 | + put(key, new FileInputStream(file), file.getName()); |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Adds an input stream to the request. |
| 100 | + * @param key the key name for the new param. |
| 101 | + * @param stream the input stream to add. |
| 102 | + */ |
| 103 | + public void put(String key, InputStream stream) { |
| 104 | + put(key, stream, null); |
94 | 105 | } |
95 | 106 |
|
96 | 107 | /** |
97 | 108 | * Adds a file to the request. |
98 | 109 | * @param key the key name for the new param. |
99 | | - * @param filedata the file contents to add. |
100 | | - * @param filename the name of the file. |
| 110 | + * @param stream the input stream to add. |
| 111 | + * @param fileName the name of the file. |
101 | 112 | */ |
102 | | - public void put(String key, InputStream filedata, String filename) { |
103 | | - put(key, filedata, filename, null); |
| 113 | + public void put(String key, InputStream stream, String fileName) { |
| 114 | + put(key, stream, fileName, null); |
104 | 115 | } |
105 | 116 |
|
106 | 117 | /** |
107 | 118 | * Adds a file to the request. |
108 | 119 | * @param key the key name for the new param. |
109 | | - * @param filedata the file contents to add. |
110 | | - * @param filename the name of the file. |
| 120 | + * @param stream the input stream to add. |
| 121 | + * @param fileName the name of the file. |
111 | 122 | * @param contentType the content type of the file, eg. application/json |
112 | 123 | */ |
113 | | - public void put(String key, InputStream filedata, String filename, String contentType) { |
114 | | - if(key != null && filedata != null) { |
115 | | - fileParams.put(key, new FileWrapper(filedata, filename, contentType)); |
| 124 | + public void put(String key, InputStream stream, String fileName, String contentType) { |
| 125 | + if(key != null && stream != null) { |
| 126 | + fileParams.put(key, new FileWrapper(stream, fileName, contentType)); |
116 | 127 | } |
117 | 128 | } |
118 | 129 |
|
|
0 commit comments