Permalink
Browse files

保存するファイル名を Timestamp から生成

  • Loading branch information...
tomykaira committed May 22, 2012
1 parent b81919b commit c660b1d82ea049fc9a39628fe9131c76e2662d05
Showing with 3 additions and 4 deletions.
  1. +3 −4 main.dart
View
@@ -1,20 +1,19 @@
#import('dart:io');
List renderResizedJpg(HttpResponse response, string size) {
- var p = Process.start('convert', ['-resize', '${size}!', 'dog.jpg', 'out_dart.jpg']);
+ var filename = 'out' + (new Date.now().value) + '.jpg';
+ var p = Process.start('convert', ['-resize', '${size}!', 'dog.jpg', filename]);
p.onExit = (exitCode) {
print('exit code: $exitCode');
p.close();
- InputStream stream = new File('out_dart.jpg').openInputStream();
+ InputStream stream = new File(filename).openInputStream();
List result = [];
stream.onData = () {
result.addAll(stream.read(1024));
- print("reading jpg");
};
stream.onClosed = () {
- print("read done");
response.headers.set(HttpHeaders.CONTENT_TYPE, 'image/jpeg');
response.outputStream.write(result);
response.outputStream.close();

0 comments on commit c660b1d

Please sign in to comment.