将文件转换为字节数组Angular 2

时间:2017-07-23 17:12:25

标签: angular typescript asp.net-web-api2

如何使用Angular2将输入文件(例如图像)转换为字节数组? 也许有人可以说什么更好:将图像转换为字节数组并将其发送到Web API或发送文件"对象"到API并在那里进行转换?

1 个答案:

答案 0 :(得分:1)

你不会真正使用Angular来解决这个任务。 JavaScript具有用于处理文件数据的API,例如 https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsArrayBuffer

See this question

PS:“Angular 2”现在被称为“Angular”,因为它们是版本4: http://angularjs.blogspot.com/2016/12/ok-let-me-explain-its-going-to-be.html

除非您的意思是使用的是旧版Angular。