如何使用 angularjs 在 mongodb 中保存 png 图像并部署

How to save png image in mongodb with angularjs and deployd

我正在开发一个应用程序,我需要从 URLS(例如 http://foo.com/bar.png)检索图像并将它们保存在 mongodb 中。该应用程序是使用 angularjs 构建的,并使用 deployd 作为 API 的东西。这是图像集的 config.js 文件:

{
    "type": "Collection",
    "properties": {
        "image": {
            "name": "image",
            "type": "image/png",
            "typeLabel": "image/png",
            "required": true,
            "id": "image",
            "order": 0
        }
    }
}

我已经尝试搜索,但我无法找到任何图像和部署。我只需要一种简单的方法来从 URL 检索图像,将它们保存在 mongodb 中,然后稍后再渲染它们。

没有列类型 image/png AFAIK。我们可以使用字符串代替它。为什么不插入图像 data uri

{
    "type": "Collection",
    "properties": {
        "image": {
            "name": "image",
            "type": "string",
            "typeLabel": "string",
            "required": true,
            "id": "image",
            "order": 0
        }
    }
}