So, I am developing an app using flutter sdk in android studio which will capture the motion sensor data and geolocator data. These data will be stored into a file (csv/ json/ bin) and that file will be uploaded into that specific bucket every 1 hour through my flutter app.
I have tried to upload data into S3 bucket using http class but this is not working. Again, everywhere there are many resources for uploading images. There are less resources for uploading file. I have also tried to use aws lambda but all tutorials are about uploading images.
Can anyone suggest me any way/tutorial/documentation about how can I upload files through my flutter to AWS S3 bucket? A code snippet is given below about how I am trying to upload data into s3 bucket.
` DatabaseHelper db = DatabaseHelper();
static const String _csvHeader = "Accelerometer, UserAccelerometer, Gyroscope, latitude-longitude\n";
List entries = [];
addEntry() async{
var res = await db.queryGeoAll(); //to get all data of geolocator from database
var geoCSV = mapListToCsv(res); //converting them into a csv file
entries.add("$accelerometer, $userAccelerometer, $gyroscope, $geoCSV");
}
clearEntries() {
accelerometer= null;
userAccelerometer= null;
gyroscope= null;
latitudeData= null;
location = null;
entries.clear();
}
void uploadSensor() async{
String csvContent = entries.join("\n");
print(csvContent);
Uri uri = Uri.parse("Bucket Adress");
http.MultipartRequest request = new http.MultipartRequest("POST", uri);
request.files.add(new http.MultipartFile.fromString("csv", _csvHeader + csvContent));
try {
return await request.send().then((response) {
if (response.statusCode == 200) {
clearEntries();
return true;
} else {
return false;
}
});
} catch (e) {
print(e.toString());
//return false;
}
}`
Here, I am getting an error like:
I/flutter ( 394): SocketException: Failed host lookup: 's3.us-east-1.aws.amazonaws.com' (OS Error: No address associated with hostname, errno = 7)
I have already added the following line to Android Manifest file
<uses-permission android:name="android.permission.INTERNET"/>
So, I am developing an app using flutter sdk in android studio which will capture the motion sensor data and geolocator data. These data will be stored into a file (csv/ json/ bin) and that file will be uploaded into that specific bucket every 1 hour through my flutter app.
I have tried to upload data into S3 bucket using http class but this is not working. Again, everywhere there are many resources for uploading images. There are less resources for uploading file. I have also tried to use aws lambda but all tutorials are about uploading images.
Can anyone suggest me any way/tutorial/documentation about how can I upload files through my flutter to AWS S3 bucket? A code snippet is given below about how I am trying to upload data into s3 bucket.
Here, I am getting an error like:
I/flutter ( 394): SocketException: Failed host lookup: 's3.us-east-1.aws.amazonaws.com' (OS Error: No address associated with hostname, errno = 7)
I have already added the following line to Android Manifest file<uses-permission android:name="android.permission.INTERNET"/>