I wonder if there are any plans to add native support for working with zip files in Dart? If not native, perhaps a library supported by the Dart team?Zip files are ubiquitous, and there are hundreds of scenarios where it is beneficial to work with them on the client side (data uploading/dowloading, parsing of xlsx files, etc). It would be awesome if Dart provided a fast standard way for dealing with it.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
--
import 'dart:io' as IO;
import 'dart:async';
import 'package:http/http.dart' as http;
import 'package:archive/archive.dart';
import 'package:unittest/unittest.dart';
void main(){
test("Test for Zip", (){
Future future = http.get("http://data.fda.gov.tw/opendata/exportDataList.do?method=ExportData&InfoId=43&logType=3")
.then((data){
Archive arc = new ZipDecoder().decodeBytes(data.bodyBytes, verify:false);
// Unzipped file has only one file. Save it as a raw json
List<int> cData= arc[0].content;
String fname = arc[0].name;
new IO.File('data/' + fname)
..createSync(recursive: true)
..writeAsBytesSync(cData);
});
expect(future, completes);
});
}
test("Test for Zip", (){
Future future = http.get("http://data.fda.gov.tw/opendata/exportDataList.do?method=ExportData&InfoId=43&logType=3")
.then((data){
Archive arc = new ZipDecoder().decodeBytes(data.bodyBytes);
// Unzipped file has only one file. Save it as a raw json
List<int> cData= arc[0].content;
String fname = arc[0].name;
/*new IO.File('data/' + fname)
..createSync(recursive: true)
..writeAsBytesSync(cData);*/
IO.IOSink sink = new IO.File('data/' + fname).openWrite();
sink.write(UTF8.decode(cData));
sink.close();
}).then((_){
});
expect(future, completes);
});