Objective: . Front-end applications allow users to select files from their local computers and send file names to the server. The server then maps these file names to files located on the server. Then the server will return a list of all matching files.
Problem: This works fine if the user selects less than a few hundred files, otherwise it may cause a long response time. I do not want to limit the number of files that the user can select, and I do not want to worry about the timeouts of http requests in the interface.
Code example:
<div>
<input (change)="add_files($event)" type="file" multiple>
</div>
add_files($event){
this.profile_service.add_files($event).subscribe(
data => console.log('request returned'),
err => console.error(err),
() =>
);
}
add_files(event_obj){
let file_arr = [];
let file_obj = event_obj.target.files;
for(let key in file_obj){
if (file_obj.hasOwnProperty(key)){
file_arr.push(file_obj[key]['name'])
}
}
let query_obj = {files:title_arr};
return this.save_files(query_obj)
}
save_files(query_obj){
let payload = JSON.stringify(query_obj);
let headers = new Headers();
headers.append('Content-Type', 'application/json');
return this.http.post('https://some_url/api/1.0/collection',payload,{headers:headers})
.map((res:Response) => res.json())
}
Possible solutions:
. , 25 , 25 . , ? , , .
, " , ". db , , db , . , , .
. angular2/observables .