Android Studio Firebase只能上传1张图片

时间:2018-06-07 16:07:40

标签: android firebase firebase-storage

当我创建StorageReference并尝试在那里保存图纸时,我只能保存1张图纸,但它不会进入正确的文件夹。如果查看图像,则会看到唯​​一创建的图像。总是当我运行应用程序并上传绘图时,会调用onfailure并且消息显示它是一个unknows错误。

public void uploadDrawing(Uri uri) {

    Toast.makeText(getActivity(), "uID: " + uID, Toast.LENGTH_LONG).show();

    String nameOfDrawing = null;

    nameOfDrawing = "drawing " + String.valueOf(System.currentTimeMillis());

    StorageReference filepath = drawingsRef.child("drawings").child(nameOfDrawing);

    filepath.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
        @Override
        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

            Toast.makeText(getActivity(), "Målningen sparades korrekt", Toast.LENGTH_SHORT).show();
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {

            Toast.makeText(getActivity(), "Något fel inträffades tyvärr", Toast.LENGTH_SHORT).show();

            Log.i("AppInfo", e.getMessage());
        }
    });
}

0 个答案:

没有答案