我正在尝试构建一个受本文启发的上传表单:
https://malcoded.com/posts/angular-file-upload-component-with-express/
我使用的是 angular 9 和 ngx-bootstrap,我没有使用对话框或有角的材料。所以,我征收了这样的上传服务:
import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import {
HttpClient,
HttpRequest,
HttpEventType,
HttpResponse,
} from '@angular/common/http';
import { environment } from '@environments/environment';
@Injectable({
providedIn: 'root',
})
export class UploadService {
private url: string = `${environment.apiUrl}/halls/file`;
constructor(private http: HttpClient) {}
public upload(
files: Set<File>
): { [key: string]: { progress: Observable<number> } } {
// this will be the our resulting map
const status: { [key: string]: { …Run Code Online (Sandbox Code Playgroud)