c# - How to read zipfile as StreamContent from httpResponseMessage? -
i send zipfile response.content:
[httpget] [route("package")] public async task<httpresponsemessage> getlogspackage() { httpresponsemessage response = new httpresponsemessage(httpstatuscode.ok); using (var stream = new memorystream()) { using (var zipfile = zipfile.read((path.combine(path, opid.tostring()) + ".zip"))) { zipfile.save(stream); response.content = new streamcontent(stream); response.content.headers.contenttype = new mediatypeheadervalue("application/octet-stream"); response.content.headers.contentlength = stream.length; } } return response; }
how stream after call method? code doesn't work( can't read zipfile) send stream.lenght ,for example, 345673, receive response 367 lenght. wrong?
var response = await _coreendpoint.getlogspackage(); using (var stream = response.content.readasstreamasync()) using (var zipfile = zipfile.read(stream)) { //do zip-file
looks should await
'ing readasstreamasync
:
using (var stream = await response.content.readasstreamasync())
currently code passing task<stream>
zipfile.read
, not intend.
Comments
Post a Comment