我是React Native的初学者。我正在开发一个应用程序,其中我使用react-native-image-picker拍照并上传到AWS服务器。我可以捕获并且可以将其上传到AWS s3当前,这些图像存储在图库中。但是我只想将它们存储在我的应用程序中(不应存储在图库中),然后上传到AWS s3。我怎样才能做到这一点。 然后,当只有网络连接时,我可以将拍摄的照片上传到AWS s3。因此,我想存储在应用程序内部,一旦恢复了网络连接,这些应该上传到AWS s3。我该如何实现。 (我没有在此处上传样式代码)
我的代码是
import React, {Component} from 'react';
import {Platform, StyleSheet,Alert, Text,TouchableOpacity,
View,Picker,Animated,Easing,Image} from 'react-native';
import ImagePicker from 'react-native-image-picker';
import { RNS3 } from 'react-native-aws3';
export default class SecondScreen extends Component<Props> {
constructor(props) {
super(props);
this.state = {
file :'',
//declare array to store all taken images
saveImages : []
}
}
takePic(){
ImagePicker.launchCamera({},(responce)=>{
const file ={
uri : responce.uri,
name :responce.fileName,,
method: 'POST',
path : responce.path,
type : responce.type,
notification: {
enabled: true
}
}
this.state.saveImages.push(file);
})
}
_upload=(saveImages)=>{
const config ={
keyPrefix :'uploads/',
bucket : 's3merahkee',
region :'us-east-2',
accessKey:'***',
secretKey :'***',
successActionStatus :201
}
this.state.saveImages.map((image) => {
RNS3.put(image,config)
.then((responce) => {
console.log(saveImages);
});
});
}
render() {
return (
<View style={styles.container}>
<View style={styles.Camera}>
<TouchableOpacity onPress={this.takePic.bind(this)}>
<Text>Take Picture</Text>
</TouchableOpacity>
</View>
<View style={styles.Send}>
<TouchableOpacity onPress={() => this._upload()}>
<Text>Send</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
答案 0 :(得分:0)
您可以提供import requests
from bs4 import BeautifulSoup
import re
import xlsxwriter
request = requests.get("http://www.drogariasnossarede.com.br/nossas-lojas")
soup = BeautifulSoup(request.content, 'html.parser')
data = soup.find_all("div", class_='item')
import csv
with open('names.csv', 'w', newline='', encoding="utf-8") as ofile:
writer = csv.writer(ofile)
for container in data:
Pharmacyname = container.find_all("h3")
Pharmacyadd = container.find_all("p")
for pharmacy in Pharmacyname:
for add in Pharmacyadd:
writer.writerow((pharmacy.text, add.text))
storageOptions.cameraRoll: false
看看API reference以获得更多选项。
对于临时存储,您可以使用react-native的AsyncStorage存储本地应用程序数据。您必须首先将图像转换为base64字符串,因为AsyncStorage只能存储字符串。