I try to upload a .jpg file to google Drive in Dart:
final access_token = '...';
// sfilePath is "/storage/emulated/0/test/"
// sfileName is "test"
Uri uri = Uri.parse('https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart');
http.MultipartRequest request = new http.MultipartRequest('POST', uri);
request.headers["Authorization"] = "Bearer $access_token";
request.fields['metadata'] = "{name : " + sfileName + '.jpg' + "};type=application/json;charset=UTF-8";
request.files.add(http.MultipartFile.fromString('metadata',
JSON.jsonEncode({'name': sfilePath + sfileName + '.jpg'}),
contentType: MediaType('application', 'json'),
));
http.StreamedResponse response = await request.send();
print('>>>>>>>>>>>>>>>>>>>>>' + response.statusCode.toString());
I get a status code bad request: 400 I saw the post about the same isue: Dart: http post upload to google Drive
What am I missing? Thanks