mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 14:04:27 +01:00
Implement artifact download functionality in Flutter web app
Added the downloadArtifact method to the ChatService class, enabling the download of artifacts in the Flutter web application. The function uses the dart:html package to trigger a browser-based file download, allowing users to save artifacts locally. This implementation complements the existing REST API and enhances the user experience.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class RestApiUtility {
|
||||
@@ -32,4 +33,19 @@ class RestApiUtility {
|
||||
throw Exception('Failed to post data');
|
||||
}
|
||||
}
|
||||
|
||||
Future<Uint8List> getBinary(String endpoint) async {
|
||||
final response = await http.get(
|
||||
Uri.parse('$_baseUrl/$endpoint'),
|
||||
headers: {"Content-Type": "application/octet-stream"},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return response.bodyBytes;
|
||||
} else if (response.statusCode == 404) {
|
||||
throw Exception('Resource not found');
|
||||
} else {
|
||||
throw Exception('Failed to load binary data');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user