Я пытаюсь загрузить файлы в firebase-storage, и загрузка начинается, потому что я вижу журналы, но затем просто останавливаюсь.
Я открываю правила, чтобы загружать их независимо от аутентификации. И симулятор работает отлично
var metadata = {
contentType: 'audio/*'
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
var storageRef = firebase.storage().ref();
var uploader = document.getElementById("uploader");
var fileButton = document.getElementById("music_files");
uploadBtn.addEventListener('click',function(e){
var file = document.getElementById("music_files").files;
var uploadTask = storageRef.child('music/' + file[0].name).put(file[0], metadata);
// Listen for state changes, errors, and completion of the upload.
uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, // or 'state_changed'
function(snapshot) {
// Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
console.log('Upload is ' + progress + '% done');
switch (snapshot.state) {
case firebase.storage.TaskState.PAUSED: // or 'paused'
console.log('Upload is paused');
break;
case firebase.storage.TaskState.RUNNING: // or 'running'
console.log('Upload is running');
break;
}
}, function(error) {
// A full list of error codes is available at
// https://firebase.google.com/docs/storage/web/handle-errors
switch (error.code) {
case 'storage/unauthorized':
// User doesn't have permission to access the object
break;
case 'storage/canceled':
// User canceled the upload
break;
case 'storage/unknown':
// Unknown error occurred, inspect error.serverResponse
break;
}
}, function() {
// Upload completed successfully, now we can get the download URL
uploadTask.snapshot.ref.getDownloadURL().then(function(downloadURL) {
console.log('File available at', downloadURL);
});
});
});
Я ожидаю иметь постоянные журналы до 100%, а затем иметь URL. Но теперь иногда он останавливается на 30 с / 40 с / 50 с% и других запусках и не показывает больше прогресса после (0%)