小编Cub*_*tic的帖子

如何从输入字段将图像上传到 firebase 云存储?

我有一个输入字段,用户可以在其中选择他们想要上传的图像,然后我需要发送到云存储。问题是,我不知道如何获取他们选择的文件。我看到了很多的问题,如这个这个这个,我看到,像这些问题等。大多数一个,所要求的预览图像之前上传。我认为我不需要预览图像,我只想上传它。我该怎么做呢?这是我当前的代码:

function addImage() {
  $("#addImage").append('\
    <input type="file" id="image" accept="image/*">\
    <button type="submit">ok</button>\
    <button onclick="cancelAddImage()">cancel</button>');
  $("#addImage").submit(function() {
    var image = $("#image").files;
    console.log(image);
    storage.ref("images").put(image).then(function(snapshot) {
      console.log('Uploaded a file!');
    });
  });
}
Run Code Online (Sandbox Code Playgroud)

为此, console.log() 给出了“未定义”。我也尝试过.files[0]代替.files;,以及许多其他人。

javascript jquery image firebase firebase-storage

6
推荐指数
1
解决办法
9245
查看次数

无法在python中导入模块

我必须安装模块“ google”,然后由于错误,在读取SO答案后,我必须手动将其卸载。从那时起,我无法导入bs4。它总是给我以下错误:

Error processing line 3 of /usr/local/lib/python3.6/dist-packages/googleapis_common_protos-1.5.3-nspkg.pth:

  Traceback (most recent call last):
    File "/usr/lib/python3.6/site.py", line 174, in addpackage
  exec(line)
    File "<string>", line 1, in <module>
    File "<frozen importlib._bootstrap>", line 568, in module_from_spec
  AttributeError: 'NoneType' object has no attribute 'loader'

Remainder of file ignored
Run Code Online (Sandbox Code Playgroud)

我在Ubuntu 17.10中使用Python 3。

python beautifulsoup

4
推荐指数
1
解决办法
1599
查看次数

python/flask 网站可以托管在 firebase 上吗?

我有一个使用 python/flask 的网站,我知道 firebase 托管仅适用于静态网站,但我需要能够在我的应用程序中使用 firebase 云功能,并且需要 firebase 托管(如果我错了,请纠正我) )。由于 Node js 是服务器端,但您可以将它与 Firebase 托管一起使用,我希望也有一种使用 Python 的方法。否则,如果有一种方法可以在没有 Firebase 托管的情况下使用云功能,您也可以告诉我。

python flask firebase firebase-hosting

3
推荐指数
1
解决办法
1万
查看次数