Created
November 3, 2022 00:04
-
-
Save taufiksu/8cab7eeeb83f4fa418a7d13ec67c1aed to your computer and use it in GitHub Desktop.
Upload API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future upload( | |
String token, String project, List<int> file, String ext) async { | |
try { | |
String uri = 'https://io.etter.cloud/v4/upload'; | |
var request = http.MultipartRequest('POST', Uri.parse(uri)); | |
request.fields['token'] = token; | |
request.fields['project'] = project; | |
request.files.add(http.MultipartFile.fromBytes('file', file, | |
filename: 'filename.' + ext)); | |
var response = await request.send(); | |
if (kDebugMode) { | |
print(response); | |
} | |
if (response.statusCode == 200) { | |
final res = await http.Response.fromStream(response); | |
if (kDebugMode) { | |
print(res.body); | |
} | |
return res.body; | |
} else { | |
return []; | |
} | |
} catch (e) { | |
return []; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment