Im trying to download a file *.Apk from the storage and install when is completed.
i revised the rules from storage and the uses.
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read : if request.auth.uid != null;
}
}
}
on rules monitor all operations are accepted but the file can't be donwloaded
fragment of donwload code is:
public void downloadUpdate() {
StorageReference gsReference = FirebaseStorage.getInstance("filename.apk");
final String rutadestino = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/";
final String nombrearchivo = "LeaderBoard-Upd.apk";
final Uri archivodestino = Uri.parse("file://" + rutadestino+nombrearchivo);
File localFile = new File(rutadestino+nombrearchivo);
if (localFile.exists()) {
localFile.delete();
}
gsReference.getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
//Local temp file has been created
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Uri contentUri = FileProvider.getUriForFile(getApplicationContext(), BuildConfig.APPLICATION_ID + ".provider", new File(rutadestino+nombrearchivo));
Intent install = new Intent(Intent.ACTION_VIEW);
install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
install.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
install.setData(contentUri);
startActivity(install);
//unregisterReceiver(this);
finish();
} else {
Intent install = new Intent(Intent.ACTION_VIEW);
install.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
install.setDataAndType(archivodestino,
"application/vnd.android.package-archive");
startActivity(install);
//unregisterReceiver(this);
finish();
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
int errorCode = ((StorageException) exception).getErrorCode();
String errorMessage = exception.getMessage();
Emergente.ErrorCode(1,getApplicationContext());
}
});
}
i received
errorcode "13000"
errorMessage "An unknown error occurred, please check the HTTP result code and inner exception for server response."
cause "open failed: EACCES (Permission denied)"
Maybe another code fragment is wrong, but in this momment im stucked on the OnFailureListener
question from:
https://stackoverflow.com/questions/65672085/error-unknown-downloading-file-from-firebase-storage 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…