小编Wol*_*dog的帖子

显示来自MongoDB的图像,该图像存储为Buffer

所以我要存储这样的图像:

router.post('/', upload.single('pic'), (req, res) => {
var newImg = fs.readFileSync(req.file.path);
var encImg = newImg.toString('base64');
var s = new Buffer(encImg, 'base64');

var newCar = {
    picture: s,
    contentType: req.file.mimetype,
    link: req.body.link
}
})
});
Run Code Online (Sandbox Code Playgroud)

现在数据看起来像这样:

{
    _id: 5a502869eb1eb10cc4449335,
    picture: Binary { _bsontype: 'Binary', 
                      sub_type: 0, 
                      position: 1230326, 
                      buffer: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 
                      48 44 52 00 00 05 00 00 00 03 1e 08 06 00  ... >
                    },
    contentType: …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js

5
推荐指数
1
解决办法
608
查看次数

反应原生Flex高度

所以我正在学习React Native Flex,并遇到了这个问题:

  • 标题:红色
  • 身体:绿色
  • 页脚:蓝色

让我们只关注正文及其内容。

<View style={styles.body}>
  <View style={styles.container}>
    <View style={styles.yellow}></View>
    <View style={styles.orange}></View>
  </View>
</View>

body: {
  flex: 15,
  justifyContent: 'center',
  alignContent: 'center',
}
Run Code Online (Sandbox Code Playgroud)

在Body内部,我希望有一个类似容器的容器,其中可以容纳元素。

1)如果我给flex <1,我只会将其缩小。

container: {
   flex: 0.9,
   flexDirection: 'row',
}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

2)如果我给出宽度和高度,则只有宽度有效。

container: {
   flex: 1,
   flexDirection: 'row',
   width: '90%',
   height: '90%', // doesn't work?
   alignSelf: 'center' // had to add this, without it, container would stick to left side
}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

3)添加保证金百分比,将整个容器固定在底部,并且alignSelf不起作用。

4)将边距添加为数字是可行的,但是我要避免使用纯数字,因为它们在其他设备上看起来有所不同。(也是,这是需要的)

在此处输入图片说明

我如何从上一张图片获得效果,但只能使用flex和width,height(以%为单位)?可能吗?

另外,对于这种情况有什么好的做法?

layout flexbox react-native

2
推荐指数
1
解决办法
4358
查看次数

标签 统计

flexbox ×1

layout ×1

mongodb ×1

mongoose ×1

node.js ×1

react-native ×1