I have experience with C # backend and ASP.Net MVC. Now I am making my first attempt at Angular 2. It takes time, but I like most of it. Now I'm stuck in a simple file upload.
I have read all the examples that I found here in Stackoverflow, but I'm still not working on my example.
On the server side, I have this C # code:
public ActionResult DownloadPicture(long id)
{
var bytes = System.IO.File.ReadAllBytes("images\dummy.jpg");
return GetAttachement(bytes, "DummyFile.jpg");
}
private ActionResult GetAttachement(byte[] bytes, string fileName)
{
var contentType = MimeMapping.GetMimeMapping(fileName);
var contentDisposition = new System.Net.Mime.ContentDisposition
{
FileName = fileName,
Inline = true
};
Response.AppendHeader("Content-Disposition", contentDisposition.ToString());
return File(bytes, contentType);
}
On the client side, I have this Typescript code:
public pictureDownload(id: number): void {
let options = new RequestOptions({ search: new URLSearchParams("id=" + id) });
this.http.get(this.urlPictureDownload, options).subscribe((data: any) => {
});
}
The request arrives at the server. The array is loading. I think my problem lies with the client. Can anyone help me out?
source
share