LoadRunner Uploading a file solution (large file) Recently, do a massive storage-related project
Test, you need to simulate a lot of uploading and downloading of files via LR, the request is rest or soap, and also the simulation of a variety of files of different sizes. Typically, a simple post protocol is used:
method One:
Web_submit_data ("Importstudent.do", "action=https://testserver/console/importstudent.do", "Method=POST", "EncType =multipart/form-data "," reccontenttype=text/html "," referer=https://testserver/console/displaystudentlist.do "," Snapshot=t12.inf "," Mode=http ", ItemData," Name=uploadfile "," Value=d://excel//data161955.zip "," File=yes ", ENDITEM, last); |
After the upload of the file MD5 value comparison, found inconsistencies, after careful review, found that the uploaded file content was LoadRunner added a few lines of additional values, Content-type, helpless, rewrite the way to read the file, I through the following program to achieve 1 to 10M text file upload, If you upload a binary file, the body's wording changes:
Method Two:
Vuser_init () {char filename[] = "D:/script/createobj_10m/tools.zip"; int len = 0;int readlen=0;int tmplen=1;int runLen =10 4857;int CLen = 0;if ((File_stream = fopen (FileName, "RB")) = = NULL) {lr_message ("Open File failed!\n"); return-1;} Fseek (File_stream, 0, 2); len = Ftell (File_stream); lr_message ("File length is:%d bytes", len); readbuf = (char *) malloc (l en+1); memset (readbuf, 0, len+1); if (Runlen > len) {runlen = Len;} Fseek (file_stream, 0, 0); while (feof (file_stream) = = 0) {Tmplen = fread (Readbuf + Readlen, 1,runlen, file_stream); Readlen + = Tmplen;clen = Readlen + runlen;if (CLen > Len) {runlen = Clen-len;} if (tmplen==0) {break;}} |
LoadRunner Upload file solution (large file)