如何在Firebase数据库中上传视频?

时间:2016-10-20 22:08:09

标签: firebase firebase-realtime-database firebase-storage

可以帮助我了解如何在Firebase数据库中上传视频......,

// Create file metadata including the content type
var metadata = {
    contentType: 'image/jpeg',
};

// Upload the file and metadata
var uploadTask = storageRef.child('images/mountains.jpg').put(file, metadata);

1 个答案:

答案 0 :(得分:0)

您无法使用实时数据库来存储/上传文件(我想您在存储大型文件时考虑了RDBMS中的BLOB / CLOB)。

您可以尝试将其上传为a Blob or File

var file = ... // use the Blob or File API
ref.put(file).then(function(snapshot) {
    console.log('Uploaded a blob or file!');
});

或作为Byte Array,在文档中讨论

// Uint8Array
var bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21]);
ref.put(bytes).then(function(snapshot) {
    console.log('Uploaded an array!');
});