gpt4 book ai didi

android - 在网络上上传图像 : getting html source code as response

转载 作者:行者123 更新时间:2023-11-29 02:06:56 26 4
gpt4 key购买 nike

我正在尝试在网络服务器上上传图片,但每当它尝试时,它都会向我发送 html 源代码作为响应,并且图片没有上传到那里。我的代码是:

HttpClient client = new DefaultHttpClient();

HttpPost post = new HttpPost(url);

ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
bitMap.compress(Bitmap.CompressFormat.JPEG, 100, byteStream);
byte[] buffer = byteStream.toByteArray();

ByteArrayBody body = new ByteArrayBody(buffer,"profile_image");


MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

entity.addPart("b@gmail.com.jpg", body);

post.setEntity(entity);


System.out.println("post entity length "+entity.getContentLength());
ResponseHandler handler = new BasicResponseHandler() ;

String response = client.execute(post,handler);

提前致谢!!!

最佳答案

关于android - 在网络上上传图像 : getting html source code as response,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9498802/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com