John

John

  • NA
  • 928
  • 131.1k

Upload file using WebClient

Sep 22 2017 6:45 AM
Stream stream = file.InputStream;
file.SaveAs(physicalPath);
BinaryReader b = new BinaryReader(file.InputStream);
byte[] fileData = b.ReadBytes(file.ContentLength);
var wc = new WebClient();
wc.Headers.Add("Authorization", "Bearer "+ AccessToken);
byte[] response = wc.UploadData(url, "PUT", fileData);
string s = wc.Encoding.GetString(response);
var obj = JObject.Parse(s);
 
 
Above code is not working with Large Files
In web.config i have updated
<httpRuntime maxRequestLength="1048576" />
still not working 

Answers (3)