I've got a simple file upload system in my app that uploads a .mp3 file to firebase. I would like to check to make sure the file being uploaded is definitely a .mp3 file and is no bigger than 80MB. Is there a way to do this?
Here is my code for uploading the files, at the moment:
private void getMixForUpload() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("mp3/*");
Intent chooser = Intent.createChooser(intent, "Choose Your Mix");
startActivityForResult(chooser, ACTION_REQUEST_GALLERY);
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == ACTION_REQUEST_GALLERY && resultCode == RESULT_OK) {
Uri uri = data.getData();
StorageReference filepath = FirebaseStorage.getInstance().getReference().child("DjMixes").child(uri.getLastPathSegment());
filepath.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
taskSnapshot.getMetadata().getReference().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Uri downloadUrl = uri;
firebaselogourl = downloadUrl.toString();
}
});
}
});
}