我试图将图片文件上传到网址位置。虽然响应状态代码即将到来pagination
。但图像没有上传。连接输入流正在200
投掷Internal Server Error
。下面是我的输出代码:
status=500
输出:
package pack;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.nio.channels.FileChannel;
import java.nio.channels.WritableByteChannel;
import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.io.FileUtils;
public class TESTTEST {
/**
* @param args
* @throws IOException
*/
public void go() throws IOException{
URL url = new URL("https://mobcsao.com/fwct-provider/api/v1/clients/67/images");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.addRequestProperty("Authorization", "Basic " +"d3BpdHM6cGFzc3dvcmQ=");
conn.addRequestProperty("Fineract-Platform-TenantId", "default");
conn.addRequestProperty("Content-Type", "multipart/form-data");
conn.setReadTimeout(10000);
conn.setConnectTimeout(15000);
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
OutputStream outputStream=conn.getOutputStream();
FileUtils.copyFile(new File("/home/wpitnew/json_example/index.png"), outputStream);
conn.connect();
conn.getResponseCode();
conn.getResponseMessage();
System.out.println(conn.getResponseCode()+" : "+conn.getResponseMessage());
InputStream inputStream=conn.getInputStream();
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(inputStream));
String abc="";
while ((abc=bufferedReader.readLine())!=null) {
System.out.println(abc);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
new TESTTEST().go();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
当我看到位置时,没有找到图像。我在哪里错了......还有其他选择吗?