c# - Endpoint which accepts a HttpPostedFileBase and writes the incoming stream to a Webclient for upload -
i have endpoint accepts httppostedfilebase, provides input stream can read download file. don't want read - want re-post endpoint on different domain (this because api built on top of another).
can without waiting whole stream read? don't want users of endpoint delayed unnecessarily.
public actionresult upload(httppostedfilebase image) string url = "www.example.com"; using (var wb = new webclient()) { var stream = wb.openwrite(url, "post"); int read; byte[] buffer = new byte[0x1000]; while ((read = image.inputstream.read(buffer, 0, buffer.length)) > 0) stream.write(buffer, 0, read); } }
unfortunately using openwrite doesn't seem provide easy option read response, i'll buffer entire stream , use uploaddata :(.
Comments
Post a Comment