每当我尝试使用高速互联网连接上传文件时,它都会上传,但互联网连接速度稍慢(即 20-30kbps),它不会上传任何内容并给出错误:“无法编码未保存的 ParseFile 等等,等等,等等。这是我的武器库:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 17 && resultCode == RESULT_OK && data != null){
Uri selectedImage = data.getData();
try{
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(),selectedImage);
Log.i("AppInfo","Images Recieved !");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG,80,byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
ParseFile parseFile = new ParseFile("photo.png",bytes);
ParseObject parseObject = new ParseObject("images");
parseObject.put("username",ParseUser.getCurrentUser().getUsername());
parseObject.put("image",parseFile);
parseObject.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if(e == null){
alert("Uploaded","Image Uploaded Successfully !");
}else{
alert("Failed","Failed because "+e.getMessage().toString());
}
}
});
}catch (IOException ioe){
ioe.printStackTrace();
alert("Failed","Failed because "+ioe.getMessage().toString());
}
}
}
期待大家的反馈!