我可以发送来自文件或Blob的数据流,并在Angular 5中以JSON格式发布它吗?我尝试使用FileReader,但无法使用result属性从其中获取流。
let blobfile=new Blob([this.curResume]);
let fr=new FileReader;
fr.readAsText(blobfile);
console.log(fr,fr.result);
这就是我尝试的方法,这是我在控制台中得到的结果。console output
发布于 2018-05-31 16:35:33
我知道您正在尝试使用POST API调用将文件推送到服务器。在这种情况下,您可以将其作为formData传递。
在添加您的问题时,请稍稍夸张一点。
const fileData= new Blob([this.yourFile], { type: "<your File type>" });
const formData = new FormData();
formData.append("yourFile", fileData);
this.httpClient.post(<your url>, formData);
https://stackoverflow.com/questions/50619913
复制相似问题