所以我要存储这样的图像:
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) 所以我正在学习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(以%为单位)?可能吗?
另外,对于这种情况有什么好的做法?