맞아, 나는 마침내이 작업을했습니다.
here에 설명 된 새로운 firebase 저장소 업로드 방법을 사용하려는 경우 더 이상 Cordova FileTransfer 플러그인을 사용하지 않아도됩니다 (더러운 작업을 수행함).
이제 (ng) Cordova File 플러그인을 사용하여 파일을 먼저 읽어야합니다. 파일에 따라 read it을 가장 적절한 방법으로 사용해야합니다. 제 경우에는 비디오를 읽으려고했기 때문에 배열 버퍼로 읽습니다. 일단
당신이 (구문을 시청)의 Blob로 변환 한 다음 업로드가 원활하게 실행됩니다 필요 읽기 :
var file_path = "root/to/directory";
var name = "filename.mp4";
$cordovaFile.readAsArrayBuffer(file_path, name)
.then(function (success) {
// success
console.log(success);
blob = new Blob([success], {type: "video/mp4"});
console.log(blob);
var uploadTask = storageRef.child(name).put(blob);
uploadTask.on('state_changed', function(snapshot){
// Observe state change events such as progress, pause, and resume
// See below for more detail
var progress = (snapshot.bytesTransferred/snapshot.totalBytes) * 100;
console.log('Upload is ' + progress + '% done');
}, function(error) {
// Handle unsuccessful uploads
console.log("Error uploading: " + error)
}, function() {
// Handle successful uploads on complete
// For instance, get the download URL: https://firebasestorage.googleapis.com/...
var downloadURL = uploadTask.snapshot.downloadURL;
console.log("Success!", downloadURL);
});
}, function (error) {
// error
console.log("Failed to read video file from directory, error.code);
}
);
NB : 1)이 웹/자바 스크립트 API를 의미 - 안드로이드 iOS API는 다를 것입니다. 2) 장치에 따라 파일 유형이 다를 수 있으므로이 문제를 해결해야합니다. 3) ngCordova를 사용하고 있지만 일반 cordova/phonegap 플러그인에도 동일하게 적용됩니다.
희망이 있으면 도움이 될 것입니다.
이미 업데이트해야 할 사항은 모두 firebase 3 구문입니다. http://stackoverflow.com/questions/34380654/uploading-video-to-firebase-uing-ngcordova-cordovacapture-in-ionic-framework –
아니요, 대답은 당신은 "firebase 데이터베이스"에 ** 로컬 비디오 경로 **를 추가하는 것과 관련된 거래만을 참조합니다. 나는 그 지역 비디오 파일 자체를 새로운 "firebase storage"에 업로드하는 방법을 고민 중이다. – Goose