我在前端使用angular和node,在后端使用springboot。使用邮递员将图像发布到S3时,图像可以成功发布,但是,当使用我的Web应用程序时,图像会以一串长长的字符/字母/符号发布。我在做什么错了?
HTML:
<input type="file" (change)="onFileSelected($event)">
<button mat-raised-button type="button" mat-button color="primary" (click)="onUpload()">Upload</button>```
.ts:
```import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component ({
selector: 'upload-images',templateUrl: './upload-images.html',styleUrls: ['./upload-images.css']
})
export class UploadImagesComponent {
selectedFile: File = null;
constructor(private http: HttpClient) {}
onFileSelected(event) {
this.selectedFile = <File>event.target.files[0];
}
onUpload() {
const formData = new FormData();
formData.append('file-0',this.selectedFile,this.selectedFile.name);
this.http.post('http://localhost:3000/storage/uploadFile',formData)
.subscribe(res => {
console.log(res);
});
}
}```