3

How can I convert input file(image,for example) to byte array by using Angular2 ? Maybe someone can say what is better: convert image to byte array and send it to Web API or send the File "object" to API and there convert it?

C.Daniel
  • 59
  • 1
  • 2
  • 7
  • I would go for convert then send, that way you can send by streams and also crypt it if needed more easily. – Vega Jul 23 '17 at 17:25

1 Answers1

0

You wouldn't really use Angular for solving this task. JavaScript has APIs for handling File data, e.g. https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsArrayBuffer

See this question

PS: "Angular 2" is just called "Angular" now, because they're on version 4:

As you might have already guessed, the term “Angular 2” is also kind of deprecated once we get to version 4, 5 etc. That said, we should start naming it simply “Angular” without the version suffix.

http://angularjs.blogspot.com/2016/12/ok-let-me-explain-its-going-to-be.html

Unless you mean you are using an older version of Angular (from closer to when "Angular 2" released).

JHS
  • 1,423
  • 17
  • 29
  • 1
    Wish you had posted some data from links in your answer. Because I can not access angularjs.blogspot.com due to office network restrictions. – Haripriya Mar 05 '20 at 07:19