【问题标题】:How to upload videos in Firebase database?如何在 Firebase 数据库中上传视频?
【发布时间】:2016-10-21 08:57:26
【问题描述】:

谁能帮助我在 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);

【问题讨论】:

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


    【解决方案1】:

    您不能使用实时数据库来存储/上传文件(我猜您在存储大文件时会想到 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!');
    });
    

    【讨论】:

      猜你喜欢
      • 2021-04-26
      • 1970-01-01
      • 1970-01-01
      • 2020-08-16
      • 2012-04-19
      • 2016-10-20
      • 1970-01-01
      • 1970-01-01
      • 2014-04-04
      相关资源
      最近更新 更多