Skip to content

Instantly share code, notes, and snippets.

View sourabhv's full-sized avatar

Sourabh Verma sourabhv

View GitHub Profile
@sourabhv
sourabhv / multipart.java
Created March 22, 2017 16:53 — forked from mcxiaoke/multipart.java
multipart request using httpurlconnection
public String multipartRequest(String urlTo, String post, String filepath, String filefield) throws ParseException, IOException {
HttpURLConnection connection = null;
DataOutputStream outputStream = null;
InputStream inputStream = null;
String twoHyphens = "--";
String boundary = "*****"+Long.toString(System.currentTimeMillis())+"*****";
String lineEnd = "\r\n";
String result = "";
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software