Chromium Code Reviews| 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.
|
| + }); |
| +} |