En mi caso, solo obtuve la última foto de los datos del formulario. Quiero todas las fotos para enviar backend.
archivo my.ts.component,
await Promise.all(blobUrls.map(async (blobUrl) => { const blob = await fetch(blobUrl).then(fetched => fetched.blob()); this.formData = new FormData(); this.formData.append('file', blob); })); const { url } = await this.service.uploadFile(this.clientId, this.formData, uuidv4()) .toPromise().catch(err => { this.cliApiService.handleErrorMessage(err); throw err; });En servicio.ts,
uploadFile(client_id: string, formData, filename: string): Observable<any> { const options = this.generateFormOption(true); const queryUri = `${this.apiEndpoint}${this.apiPath}/storage/upload/${client_id}/${filename}`; return this.http.post<any[]>(queryUri, formData, options); }en matraz,
storage_image_file_request.add_argument('file', location='files', required=True) class ImageUploadResource(BaseResource): @ns_storage.marshal_with(storage_image_url_message) def post(self, client_id: str, filename: str): args = storage_image_file_request.parse_args() files = args.get('file')Quiero enviar todos los datos de formulario y también quiero obtener todos los datos de formulario en el matraz. Ahora, solo obtengo una foto, incluso subo dos fotos.
Declarando así puede resolver mi problema.
export class myComponent implements OnInit { formData = new FormData(); await Promise.all(blobUrls.map(async (blobUrl) => { const blob = await fetch(blobUrl).then(fetched => fetched.blob()); this.formData.append('file', blob); })); }