EDIT: I have added in 'recRef' ".3gp" at the end of the reference and now when I use the emulator it uploads as .3gp file of 0KB and external device still uploads an "application/octet-stream" file (weight 0KB).
I made a record activity to my app and I just cannot upload it properly to firebase storage. I tried to build an upload process based on the image upload example google published and it uploads an empty file (0KB, type "application/octet-stream"). the recording process is working excellent and I made a play button to check it so I know that it only a problem that I don't know how to upload it properly to the cloud.
You all welcome to use my popup record activity from git: https://github.com/tidharon/Popup-Record-Window-App
Heres my uploading code:
recRef = storage.getReference(lastAct + " Records").child(lastTitle);
metadata = new StorageMetadata.Builder().setCustomMetadata(lastID, outputFile).build();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] daata = baos.toByteArray();
uploadTask = (UploadTask) recRef.putBytes(daata, metadata).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
recURL = recRef.toString();
getIntent().putExtra("recURL", recURL);
}
});
recRef is a StorageReference element. metadata is a StorageMetadate element. lastID is the ID of the text document connected to the record. outputFile is the directory where the record is stored
This is the preparation for the recording process:
outputFile = Environment.getExternalStorageDirectory().getAbsolutePath() + ("/" + lastAct + " | " + lastID + " | " + date + ".3gp");
myAudioRecorder = new MediaRecorder();
myAudioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
myAudioRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
myAudioRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
myAudioRecorder.setOutputFile(outputFile);
Thanks in advance!