Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. upload(file) {
  2. const req = new HttpRequest('POST', this.urlUpload, file, {
  3. headers: new HttpHeaders({'Content-Type':'multipart/form-data'}),
  4. reportProgress: true
  5. });
  6. return this.http.request(req);
  7. }
  8.  
  9. download() {
  10. this.downloader.download().subscribe(event => {
  11. if (event.type === HttpEventType.DownloadProgress) {
  12. } else if (event instanceof HttpResponse) {
  13. this.upload(event.body);
  14. }
  15. });
  16. }
  17.  
  18. upload(file) {
  19. this.downloader.upload(file).subscribe( event => {
  20. if (event.type === HttpEventType.UploadProgress) {
  21. } else if (event instanceof HttpResponse) {
  22. console.log('File is completly uploaded!');
  23. }
  24. });
  25. }
  26.  
  27. @PostMapping("/uploadFile")
  28. public UploadFileResponse uploadFile(@RequestParam("file") MultipartFile file) {
  29. return ...;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement