Back4App上传一个小型文件,但抛出错误:无法编码未保存的ParseFile

时间:2018-06-03 03:59:39

标签: java android back4app

每当我尝试上传具有高速互联网连接的文件时,它上传,但互联网连接速度稍慢(即20-30kbps),它没有上传任何内容并给出错误:"无法编码未保存的ParseFile blah,blah,blah。这是我的武器库:

@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());

        }
    }
}

期待您的反馈!

0 个答案:

没有答案