Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Unified Diff: recipes/dart_io/pkg_http/bin/getting_response_content_in_binary_format.dart

Issue 99333012: The first few short pkg:http examples (Closed) Base URL: https://github.com/dart-lang/cookbook.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: recipes/dart_io/pkg_http/bin/getting_response_content_in_binary_format.dart
diff --git a/recipes/dart_io/pkg_http/bin/getting_response_content_in_binary_format.dart b/recipes/dart_io/pkg_http/bin/getting_response_content_in_binary_format.dart
new file mode 100644
index 0000000000000000000000000000000000000000..87051010d3287bf93fa10e51c10e3e51c80a0f89
--- /dev/null
+++ b/recipes/dart_io/pkg_http/bin/getting_response_content_in_binary_format.dart
@@ -0,0 +1,11 @@
+import 'package:http/http.dart' as http;
+import 'package:crypto/crypto.dart';
+
+void main() {
+ var url = "https://www.dartlang.org/logos/dart-logo.png";
+ http.get(url).then((response) {
+ var bytes = response.bodyBytes;
Anders Johnsen 2013/12/06 11:53:28 var -> List<int>
shailentuli 2013/12/06 18:16:29 Done.
+ // Do something with the bytes.
+ var base64 = CryptoUtils.bytesToBase64(bytes);
Anders Johnsen 2013/12/06 11:53:28 var -> String
shailentuli 2013/12/06 18:16:29 Done.
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698