my RN app is created with create react native app. Now i want to display some images of my aws s3 bucket.
So this works fine, if i make the images public and display them with:
<Image source={props.pic_url} />
But of course the images should be private, so i try to load them with the S3 API:
export const s3 = new AWS.S3({
apiVersion: '2006-03-01',
params: {Bucket: BUCKET_NAME}
});
let get_pic_params = {
Bucket: BUCKET_NAME,
Key: "pics/0001.jpg"
}
s3.getObject(get_pic_params, function(err, data) {
if (err) {
console.log('There was an error getting a pic: ' + err.message);
} else {
console.log(data);
}
});
Output:
Object {
"AcceptRanges": "bytes",
"Body": Object {
"data": Array [
71,
73,
70,
56,
.
.
.
59,
],
"type": "Buffer",
},
"ContentLength": 45212,
"ContentType": "image/jpeg",
"ETag": "\"c90bf3bb902711c8b1386937341ca9ec\"",
"LastModified": 2017-09-13T12:40:35.000Z,
"Metadata": Object {},
}
This works fine, but i dont want to get the data as a console.log i want to display them as an Image. How can i do that with create-react-native-app?
I tried react-native-fs but that does not work with create-react-native-app