【问题标题】:How to upload files to firebase using HTTPClient Module in Angular?如何使用 Angular 中的 HTTPClient 模块将文件上传到 Firebase?
【发布时间】:2020-06-11 08:26:42
【问题描述】:

我通过开发一个简单的购物网站克隆网络应用程序开始学习 Angular,使用 firebase 作为后端。我使用 HTTP 请求(get/post/put)来检索和修改 firebase 中的数据。

有没有办法使用 HTTP 请求将图像上传到 Firebase 存储?如果是这样,请在这些方面提供帮助!

【问题讨论】:

    标签: angular typescript firebase angular-httpclient angular-http


    【解决方案1】:
    fileUploader() {
        const file = ... // assign the image file here
        ref.put(file).then(function(snapshot) {
            console.log('Uploaded the file!');
        });
    }
    

    是的,您使用上述方法将文件存储到云存储。

    【讨论】:

    • 我正在使用firebase提供的rest api通过http请求连接实时数据库,例如this.httpClient.put('REST API URL'+rowId+'.json', userData)。那么有没有办法使用这种方法将图像上传到firebase?
    • 您无法将文件存储在实时数据库中。您需要使用 Firebase 云存储
    猜你喜欢
    • 1970-01-01
    • 2017-08-15
    • 2019-07-30
    • 2020-05-07
    • 1970-01-01
    • 1970-01-01
    • 2019-11-14
    • 2019-03-29
    • 1970-01-01
    相关资源
    最近更新 更多