0

In a ASP.Net Core 2.1 App I am writing byte array as a pdf file to a location with below code

byte[] arr = await rpt.BuildFile(actionContextAccessor.ActionContext);
System.IO.File.WriteAllBytes(Path.Combine(env.WebRootPath, "Storage", "PDF", HttpContext.Session.GetString("UserID"), Name), arr);

Now I also want to store same byte array as pdf over a http location

  string _path = "http://MyApps.in/document_1/" + Model.Identifier.Substring(0, 4) + "/" + Name;
  System.IO.File.WriteAllBytes(_path, arr);

But it does not seems to work this way look like File.WriteAllBytes does not write over HTTP location.

How can I write pdf file over HTTP location ??

Kiran Joshi
  • 1,758
  • 2
  • 11
  • 34
Tanwer
  • 1,503
  • 8
  • 26
  • 41
  • 1
    You would need to use a http client and POST to the desired location provided a handler exists at that endponit – Nkosi Aug 18 '18 at 06:51
  • do you mean you want to write a byte array over HTTP... so the PDF can be downloaded? – Adam Vincent Aug 18 '18 at 07:28
  • No , don't want to download it , just want to store it there as backup – Tanwer Aug 18 '18 at 08:00
  • See https://stackoverflow.com/questions/23518817/send-byte-array-by-http-post-in-store-app for an example how to post a byte array. if you need method=put HttpClient.PutAsync exists. – Christoph Lütjen Aug 18 '18 at 12:40

0 Answers0