-3

Firebase gives -13000 StorageException when i try to upload a file at a location which doesn't exists.

Example :

root/abc/cba/pqr/test_file.txt

but root/test_file.txt and root/abc/test_file.txt both work fine

final File file = new File("local/file_path.txt");
StorageReference remoteLocation = FirebaseStorage.getInstance().getReference();
StorageReference currentFileRef = remoteLocation.child("abc/cba/pqr/test_file.txt");
StorageTask task = currentFileRef.putFile(Uri.fromFile(file))
            .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                @Override
                public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                    String log = "File " + file.getName() + " uploaded successfully !";
                    uploadLog(log);
                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception exception) {
                    String log = "File " + file.getName() + " upload Error : "+exception.getClass().getSimpleName()+" " + exception.getCause()+" "+exception.getLocalizedMessage()+" " +exception.getMessage();
                    if (exception instanceof StorageException){
                        log+= " "+((StorageException)exception).getErrorCode();
                        log+= " "+((StorageException)exception).getHttpResultCode();
                    }
                    uploadLog(log);
                    Log.d(TAG,log);
                }
            });

I have updated version of google play services and all the required permissions.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

Check whether you had provided READ_EXTERNAL_STORAGE permission for your application both in manifest and run-time.

Read Storage is a Dangerous Permission. For Dangerous Permsssions in The app should have Runtime permmsions

eginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app.

System permissions are divided into two categories, normal and dangerous:

  • Normal permissions do not directly risk the user's privacy. If your app lists a normal permission in its manifest, the system grants the permission automatically.

  • Dangerous permissions can give the app access to the user's confidential data. If your app lists a normal permission in its manifest, the system grants the permission automatically. If you list a dangerous permission, the user has to explicitly give approval to your app.

Requesting Run Time Permissions in Android

To Check Whether if it is the problem. Go to Settings -> Applications -> Your Application -> Permissions -> Allow Storage Permission.*

  • To Do This You Must HAve Read Storage Permission in Manifest..

To Add Run Time Permissions

  1. Requesting Run Time Permission
  2. Run time permission above Marshmallow
Tomin B Azhakathu
  • 2,656
  • 1
  • 19
  • 28
  • I have this permission READ_EXTERNAL_STORAGE and since i mentioned uploads of the format root/file.txt and root/abc/file.txt work fine i think the issue is at the firebase side. – Krittam Kothari Dec 16 '17 at 05:45