Use agular2 for file upload. Note: "zhuodi tornado" and "agular2" file upload.

Source: Internet
Author: User
Tags http file upload

Use agular2 for file upload. Note: "zhuodi tornado" and "agular2" file upload.

(-1) Function Description

Write a function. The foreground initiates a request to execute tasks in the background. The foreground can obtain the execution progress and obtain the final execution status.

(0) angular2 $ http File Upload

Angular-file-upload is not used here to share code.

 

 

var time = new Date().getTime();var obj = {method:"POST",url:"csvFile",headers : { 'Content-Type':undefined},transformRequest: function() {  var formData = new FormData();  formData.append('file', $('#uploadBtn')[0].files[0]);  formData.append('time',time);  return formData;  }}

 

  

'Content-type': undefined

TransformRequest

I have some online comments about these two parts. I have limited capabilities. I only know the results of doing so, but I don't know if they are right. I hope you can give me some advice.

 

(1) how to deal with multithreading

Because the interface for returning progress and final status is provided, HashMap is used in the background to store information. The number of milliseconds passed in at the front end is marked.

Removed the use of many member variables and changed to passing parameters.

Note that the front-end sends an execution request and then sends an execution progress request. In the return progress method, I wrote the following:

This writing has laid the root of the disaster, and has done bad things with good intentions. This kind of mistake is not intuitively displayed. Troubleshooting is also a great deal of effort.

 

Integer rate = rateMap.get(time) ;if(rate !=null){if(rate == 100){rateMap.remove(time);return 100;}else{return rate;}}else{return 100;}

 

Finally, if it is null, 0 is returned.

 

(2) How to export maven project groups, multi-module projects, and multiple maven Projects

In fact, you only need to export the main project (a single project) according to the normal operation. My Baidu ....

(3) Insert data

Another mistake is made here, because there will be a lot of null data. The previous writing is that when a field is null, the dao Layer Code will not be executed.

In fact, as long as the id is not null, the code is changed, and non-main data is null, the program can still execute the dao layer code.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.